/* ============================================================
   Modals · form fields · swatches · toast
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s var(--ease);
}
.modal[hidden] { display: none; }

.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s var(--ease);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 20px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  margin: 18px -20px -4px;
}
.modal-foot-spacer { flex: 1; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 12px; }
.field--grow { flex: 1; min-width: 0; }
.field--icon { flex: 0 0 86px; }

.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field-hint {
  text-transform: none;
  color: var(--ink-mute);
  font-weight: 400;
  margin-left: 6px;
  letter-spacing: 0;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"] {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 13px;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
  width: 100%;
}
.field input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: rgba(0,0,0,0.5);
}
.field input::placeholder { color: var(--ink-mute); }

#f_url { font-family: 'Geist Mono', ui-monospace, monospace; font-size: 13px; }
#f_icon { font-family: 'Geist', sans-serif; text-align: center; font-size: 18px; }

/* ---------- Color row ---------- */
.color-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

input[type="color"] {
  width: 44px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: transparent;
  padding: 3px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
  border: none; border-radius: 6px;
}

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s var(--ease);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px var(--ink);
}

/* ---------- Password field peek ---------- */
.field-input-wrap { position: relative; display: flex; }
.field-input-wrap input { padding-right: 42px; }
.field-peek {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--ink-mute);
  padding: 8px;
  cursor: pointer;
  border-radius: 6px;
}
.field-peek:hover { color: var(--ink); background: var(--surface-hov); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.22s var(--ease);
  color: var(--ink);
  max-width: calc(100vw - 40px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.toast[hidden] { display: none; }
.toast.is-error {
  border-color: rgba(224,104,104,0.5);
  color: #f0b5b5;
  background: #1b1416;
}
.toast.is-success {
  border-color: rgba(122,211,168,0.4);
  color: var(--success);
  background: #121b18;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 520px) {
  .field-row { flex-direction: column; }
  .field--icon { flex: 1; }
}
