/* ==========================================================================
   ARIA MUSE — Studio Admin
   A calm, utilitarian counterpart to the front-end's editorial aesthetic.
   ========================================================================== */

:root {
  --ink: #16161a;
  --ink-2: #1f1f25;
  --ink-3: #2a2a32;
  --paper: #f6f4f0;
  --paper-2: #ffffff;
  --paper-3: #eceae4;
  --muted: #77746c;
  --muted-2: #9c988e;
  --line: #ddd9d0;
  --line-2: #c9c4b8;
  --accent: #b08a52;
  --accent-soft: #f2e8d8;
  --ok: #3f7d54;
  --warn: #b06a3b;
  --err: #b4453f;
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --radius: 3px;
}

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- gate */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 15%, rgba(176, 138, 82, 0.09), transparent 55%),
    var(--ink);
}

.gate-card {
  width: 100%;
  max-width: 420px;
  padding: clamp(2rem, 5vw, 3rem);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.55);
}

.gate-brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.2em;
}

.gate-brand sup {
  font-family: var(--font-body);
  font-size: 0.45em;
  letter-spacing: 0;
  color: var(--accent);
  vertical-align: super;
}

.gate-sub {
  margin: 0.35rem 0 2rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate-error {
  margin-bottom: 1.25rem;
  padding: 0.7rem 0.9rem;
  background: #fbeceb;
  border-left: 3px solid var(--err);
  color: #7d2b27;
  font-size: 0.8125rem;
}

.gate-help { margin-top: 1.75rem; font-size: 0.8125rem; }

.gate-help summary {
  cursor: pointer;
  color: var(--muted);
  list-style: none;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}

.gate-help summary::-webkit-details-marker { display: none; }
.gate-help summary::before { content: "+ "; color: var(--accent); font-weight: 700; }
.gate-help[open] summary::before { content: "− "; }

.gate-help-body { padding-top: 0.75rem; color: var(--muted); }
.gate-help-body ol { margin: 0.5rem 0 0.75rem 1.1rem; list-style: decimal; }
.gate-help-body li { margin-bottom: 0.4rem; }

/* ---------------------------------------------------------------- app */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.9rem clamp(1rem, 3vw, 2.25rem);
  background: var(--ink);
  color: var(--paper);
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.topbar-brand {
  font-family: var(--font-display);
  font-size: 1.125rem;
  letter-spacing: 0.18em;
}

.topbar-brand sup {
  font-family: var(--font-body);
  font-size: 0.45em;
  color: var(--accent);
  vertical-align: super;
}

.topbar-sep { width: 1px; height: 20px; background: rgba(246, 244, 240, 0.25); }

.topbar-label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.55);
}

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.save-state {
  font-size: 0.75rem;
  color: rgba(246, 244, 240, 0.6);
  padding-right: 0.5rem;
}

.save-state.is-dirty { color: var(--accent); }

/* ---------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 clamp(1rem, 3vw, 2.25rem);
  background: var(--ink);
  border-bottom: 1px solid rgba(246, 244, 240, 0.14);
  overflow-x: auto;
}

.tab {
  padding: 0.85rem 1.1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(246, 244, 240, 0.55);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.25s, border-color 0.25s;
}

.tab:hover { color: var(--paper); }

.tab.is-active {
  color: var(--paper);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------- content */
.content {
  flex: 1;
  width: 100%;
  max-width: 940px;
  margin-inline: auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2.25rem) 4rem;
}

.panel { display: none; animation: panelIn 0.35s ease; }
.panel.is-active { display: block; }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.panel-title--spaced {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.panel-subtitle {
  margin: 2.25rem 0 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-subtitle em {
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted-2);
}

.panel-hint {
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 62ch;
}

/* -------------------------------------------------------------- fields */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.field { display: grid; gap: 0.45rem; margin-bottom: 1.25rem; }

.field-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-label em {
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted-2);
}

.field-hint { font-size: 0.75rem; color: var(--muted-2); }

.field--inline {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 0.65rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field textarea { resize: vertical; line-height: 1.65; }

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(176, 138, 82, 0.14);
}

.field input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.muted { color: var(--muted); font-size: 0.875rem; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1.4rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, opacity 0.25s;
  white-space: nowrap;
}

.btn--sm { padding: 0.55rem 1.05rem; }

.btn--solid { background: var(--accent); color: #fff; }
.btn--solid:hover { background: #97743f; }

.btn--ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--ink); }

.topbar .btn--ghost {
  border-color: rgba(246, 244, 240, 0.35);
  color: var(--paper);
}
.topbar .btn--ghost:hover { border-color: var(--paper); background: rgba(246, 244, 240, 0.1); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.linklike {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
  border: none;
  background: none;
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ------------------------------------------------------------ repeater */
.repeater { display: grid; gap: 0.9rem; margin-bottom: 1rem; }

.rep-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 1rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.rep-fields { display: grid; gap: 0.75rem; }

.rep-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }

.rep-actions { display: grid; gap: 0.35rem; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn--danger:hover { border-color: var(--err); color: var(--err); background: #fbeceb; }

.rep-thumb {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper-3);
}

/* ----------------------------------------------------------- dropzone */
.dropzone {
  position: relative;
  border: 2px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 2.25rem 1.5rem;
  text-align: center;
  background: var(--paper-2);
  transition: border-color 0.25s, background 0.25s;
  margin-bottom: 1.5rem;
}

.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }

.dropzone-icon {
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.dropzone-title { font-weight: 600; margin-bottom: 0.25rem; }

.dropzone-hint { font-size: 0.8125rem; color: var(--muted); }

.dest-toggle {
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 1rem;
  padding: 0.25rem;
  background: var(--paper-3);
  border-radius: var(--radius);
}

.dest-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.dest-opt:has(input:checked) {
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.dest-opt input { accent-color: var(--accent); }

.upload-queue { display: grid; gap: 0.5rem; margin-bottom: 1.75rem; }

.upload-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.85rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.8125rem;
}

.upload-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--paper-3);
}

.upload-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-status { font-size: 0.75rem; color: var(--muted); }
.upload-status.is-ok { color: var(--ok); }
.upload-status.is-err { color: var(--err); }

/* --------------------------------------------------------- status box */
.status-box {
  margin-top: 1.25rem;
  padding: 0.9rem 1.1rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.status-box.is-ok { border-left-color: var(--ok); }
.status-box.is-err { border-left-color: var(--err); }
.status-box.is-warn { border-left-color: var(--warn); }

.status-box code {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--paper-3);
  border-radius: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--ink);
}

/* ------------------------------------------------------------- howto */
.howto { margin: 0 0 1rem 1.1rem; list-style: decimal; color: var(--muted); }
.howto li { margin-bottom: 0.4rem; }
.howto strong { color: var(--ink); }

/* ------------------------------------------------------------- footer */
.admin-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.25rem clamp(1rem, 3vw, 2.25rem);
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
}

.admin-foot a:hover { color: var(--accent); }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.85rem 1.5rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: 0 20px 45px -18px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.35s ease;
  max-width: min(90vw, 460px);
  text-align: center;
}

.toast.is-ok { background: var(--ok); }
.toast.is-err { background: var(--err); }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* -------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(22, 22, 26, 0.72);
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 1.75rem;
  background: var(--paper-2);
  border-radius: var(--radius);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* --------------------------------------------------------- responsive */
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { gap: 0.75rem; }
  .topbar-label, .topbar-sep { display: none; }
  .save-state { width: 100%; order: 3; padding: 0; }
  .rep-row { grid-template-columns: 1fr; }
  .rep-actions { grid-auto-flow: column; justify-content: start; }
}

@media (max-width: 460px) {
  .tabs { padding-inline: 0.5rem; }
  .tab { padding: 0.75rem 0.7rem; font-size: 0.625rem; }
}
