:root {
  --navy: #14233c;
  --ink: #16181d;
  --muted: #5d6470;
  --line: #e2ddd4;
  --bg: #f4f2ee;
  --paper: #fff;
  --accent: #e8731f;
  --accent-d: #c95e10;
  --danger: #c0352b;
  --ok: #1f9d55;
  --radius: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif; font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
img, video { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
input, select, textarea { font: inherit; font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; white-space: nowrap; text-decoration: none;
  background: var(--paper); color: var(--ink); border-color: var(--line);
}
.btn:disabled { opacity: .45; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:not(:disabled):hover { background: var(--accent-d); }
.btn--dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn--danger { background: #fff; color: var(--danger); border-color: #f0c9c5; }
.btn--small { padding: 6px 12px; font-size: 14px; }
.btn--block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; font-size: 18px; color: var(--muted); display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn--danger:hover { color: var(--danger); background: #fdecea; }

/* ===== Login ===== */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.login__card { width: min(380px, 100%); background: var(--paper); border-radius: 18px; padding: 32px 26px; display: grid; gap: 16px; text-align: center; }
.login__card img { width: 140px; height: auto; margin: 0 auto; }
.login__card h1 { font-size: 22px; color: var(--navy); }
.login__card label { display: grid; gap: 6px; text-align: start; font-weight: 500; }
.login__card input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.login__error { color: var(--danger); font-weight: 500; margin: 0; }

/* ===== Top ===== */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar__logo { height: 30px; width: auto; }
.topbar__title { font-weight: 800; color: var(--navy); margin-inline-end: auto; }
.topbar__link { background: none; border: 0; color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 8px; border-radius: 8px; }
.topbar__link:hover { background: var(--bg); color: var(--ink); }

.tabs { position: sticky; top: 51px; z-index: 19; display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; background: var(--bg); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tab.is-active { background: var(--navy); color: #fff; }

.panel { max-width: 980px; margin: 0 auto; padding: 18px 14px 120px; }
.panel__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel__head h2 { font-size: 22px; color: var(--navy); }
.panel__head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ===== Cards ===== */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.card__head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--line); }
.card__body { padding: 12px; display: grid; gap: 12px; }
.card__title-input { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; font-weight: 800; font-size: 17px; color: var(--navy); background: transparent; }
.card__title-input:hover { border-color: var(--line); }
.card__title-input:focus { outline: none; border-color: var(--navy); background: var(--bg); }
.card__count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.handle { cursor: grab; color: #a8a29a; font-size: 20px; line-height: 1; padding: 6px 4px; touch-action: none; user-select: none; }
.handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 10px 24px -10px rgba(0,0,0,.35); }

.field { display: grid; gap: 5px; font-size: 14px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%; }
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--navy); background: #fff; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ===== Media grid ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; min-height: 60px; }
.grid--empty::before { content: attr(data-empty); grid-column: 1 / -1; color: var(--muted); font-size: 14px; text-align: center; padding: 18px; border: 2px dashed var(--line); border-radius: 10px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--line); border: 0; padding: 0; cursor: grab; touch-action: manipulation; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.tile__badge { position: absolute; top: 5px; inset-inline-start: 5px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; pointer-events: none; }
.tile__num { position: absolute; top: 5px; inset-inline-end: 5px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.tile__remove { position: absolute; bottom: 5px; inset-inline-end: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 13px; display: grid; place-items: center; }
.tile--uploading { cursor: default; display: grid; place-items: center; background: var(--bg); border: 2px dashed var(--line); }
.tile__progress { position: absolute; inset: auto 8px 10px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.tile__progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.tile__label { font-size: 12px; color: var(--muted); padding: 0 6px; text-align: center; }
.tile--error { border-color: #f0c9c5; }
.tile--error .tile__label { color: var(--danger); }
.tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }

.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.color-dot { width: 18px; height: 18px; border-radius: 50%; flex: none; }

/* ===== Sheets ===== */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(10,16,28,.55); display: grid; place-items: center; padding: 16px; }
.sheet__box { width: min(760px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--paper); border-radius: 16px; overflow: hidden; }
.sheet__box--small { width: min(420px, 100%); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet__head h2 { font-size: 19px; color: var(--navy); }
.sheet__hint { margin: 0; padding: 0 16px; color: var(--muted); font-size: 14px; }
.sheet__body { padding: 12px 16px; overflow: auto; display: grid; gap: 14px; }
.sheet__body h3 { font-size: 15px; color: var(--navy); margin-bottom: 6px; }
.sheet__foot { padding: 12px 16px; border-top: 1px solid var(--line); }
.sheet__foot--row { display: flex; justify-content: space-between; gap: 10px; }
.item-preview img, .item-preview video { width: 100%; max-height: 260px; object-fit: contain; background: #000; border-radius: 10px; }

/* ===== Save bar & toast ===== */
.savebar { position: fixed; inset: auto 0 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -12px rgba(0,0,0,.25); }
.savebar__status { font-size: 14px; color: var(--muted); }
.savebar.is-dirty .savebar__status { color: var(--accent-d); font-weight: 700; }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: calc(100% - 32px); text-align: center; }
.toast--error { background: var(--danger); }

@media (max-width: 600px) {
  .row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .topbar__title { display: none; }
  .topbar__logo { margin-inline-end: auto; }
  .sheet { padding: 0; align-items: end; }
  .sheet__box { border-radius: 16px 16px 0 0; max-height: 92dvh; }
}
