:root {
  --bg: #15111F;
  --shell: #1E1830;
  --surface: #241D38;
  --ink: #F5EFE3;
  --ink-soft: #B3A9CB;
  --ink-faint: #6E6486;
  --line: #362C4E;
  --accent: #FF8A5C;
  --accent-ink: #201229;
  --accent-soft: #F2C078;
  --success: #56C2AF;
  --success-bg: #1D3833;
  --danger: #F08BA8;
  --danger-bg: #3A2333;
  --shadow: 0 24px 55px -18px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--shell);
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  padding: 20px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand {
  font-family: "Zen Old Mincho", serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand span { color: var(--accent); }
.add-post-btn {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-ink);
  background: linear-gradient(135deg, #FFA275, var(--accent));
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.add-post-btn svg { width: 14px; height: 14px; }

/* ---------- Screens ---------- */
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 90px;
  display: none;
}
.screen.active { display: block; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title:first-child { margin-top: 2px; }
.count-pill {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 8px;
}

.empty-note, .loading-note {
  font-size: 12.5px;
  color: var(--ink-faint);
  padding: 14px 4px 4px;
}

/* ---------- Ticket card ---------- */
.ticket-list { display: flex; flex-direction: column; gap: 12px; }

.ticket {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  cursor: pointer;
  overflow: hidden;
}
.ticket::before, .ticket::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}
.ticket::before { left: -8px; }
.ticket::after { right: -8px; }

.t-main { flex: 1; padding: 13px 14px; min-width: 0; }
.t-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 7px;
}
.t-tag.movie { background: #3A2A20; color: #F0A87C; }
.t-tag.goods { background: #3A2F16; color: #E8B45C; }
.t-tag.event { background: #241E3F; color: #B0A4F5; }
.t-title { font-size: 14.5px; font-weight: 500; line-height: 1.45; margin-bottom: 6px; }
.t-account { font-size: 11.5px; color: var(--ink-faint); }
.t-stub {
  width: 78px; flex-shrink: 0;
  border-left: 1.5px dashed var(--line);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px;
}
.t-stub .days { font-family: "JetBrains Mono", monospace; font-weight: 600; font-size: 19px; }
.t-stub .unit { font-size: 10px; color: var(--ink-faint); }
.t-stub .date { font-size: 10px; color: var(--ink-faint); margin-top: 3px; font-family: "JetBrains Mono", monospace; }
.ticket.pending { border-left: 3px solid var(--accent); }
.ticket.pending .t-stub .days { color: var(--accent); }
.ticket.approved { border-left: 3px solid var(--success); }
.ticket.approved .t-stub .days { color: var(--success); }

/* ---------- Accounts ---------- */
.account-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: "Zen Old Mincho", serif; font-weight: 700; font-size: 14px;
  color: var(--accent-ink); flex-shrink: 0;
}
.acc-info { flex: 1; min-width: 0; }
.acc-name { font-size: 13.5px; font-weight: 500; }
.acc-handle { font-size: 11.5px; color: var(--ink-faint); font-family: "JetBrains Mono", monospace; }
.acc-remove { border: none; background: none; color: var(--ink-faint); font-size: 11.5px; cursor: pointer; padding: 6px; }
.acc-remove:hover { color: var(--danger); }

.card-box {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.card-box .box-title { font-size: 12.5px; font-weight: 700; margin-bottom: 10px; }
.field-row { display: flex; gap: 8px; margin-bottom: 8px; }
.field-row input, .field-row select, .field-row textarea {
  flex: 1; font-family: inherit; font-size: 13px;
  padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  min-width: 0;
}
.field-row textarea { resize: vertical; min-height: 90px; }
.field-row input:focus, .field-row select:focus, .field-row textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, #FFA275, var(--accent));
  color: var(--accent-ink);
  border: none; font-family: inherit; font-weight: 700; font-size: 13.5px;
  padding: 11px; border-radius: 10px; cursor: pointer;
}
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.limit-note { font-size: 11px; color: var(--ink-faint); margin-top: 8px; text-align: center; }

/* ---------- Trash ---------- */
.trash-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
}
.trash-info { flex: 1; min-width: 0; }
.trash-title { font-size: 13.5px; margin-bottom: 4px; }
.trash-meta { font-size: 11px; color: var(--ink-faint); }
.restore-btn {
  font-family: inherit; font-size: 12px; font-weight: 700;
  color: var(--success); background: var(--success-bg);
  border: none; border-radius: 999px; padding: 7px 12px; cursor: pointer; flex-shrink: 0;
}
.purge-link {
  font-size: 10.5px; color: var(--ink-faint); background: none; border: none;
  text-decoration: underline; cursor: pointer; margin-top: 3px; display: block;
}

/* ---------- Overlay (detail / add post) ---------- */
.overlay {
  position: fixed;
  inset: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--shell);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.2,.8,.3,1);
}
.overlay.open { transform: translateY(0); }
.overlay-head {
  padding: 18px 16px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.close-btn {
  background: var(--surface); border: 1px solid var(--line);
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-soft); flex-shrink: 0;
}
.overlay-head h2 { font-size: 14px; font-weight: 700; letter-spacing: .02em; margin: 0; }
.overlay-body { flex: 1; overflow-y: auto; padding: 18px 18px 100px; }

.detect-banner {
  background: var(--success-bg); color: var(--success);
  font-size: 11.5px; font-weight: 500; border-radius: 10px;
  padding: 9px 12px; margin-bottom: 18px; display: flex; align-items: center; gap: 7px;
}

.field-label {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink-soft); text-transform: uppercase;
  margin-bottom: 6px; margin-top: 16px; display: block;
}
.field-label:first-of-type { margin-top: 0; }
.detail-input, .detail-select {
  width: 100%; font-family: inherit; font-size: 15px;
  padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.detail-date { font-family: "JetBrains Mono", monospace; font-weight: 600; }

.source-quote {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent-soft); border-radius: 8px;
  padding: 12px 13px; font-size: 13px; line-height: 1.7; color: var(--ink-soft);
  margin-top: 8px;
}
.source-account {
  font-size: 11.5px; color: var(--ink-faint); font-family: "JetBrains Mono", monospace; margin-top: 8px;
}

.image-drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.6;
}
.image-drop-zone:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.image-drop-zone.has-image { padding: 8px; cursor: default; }
.image-drop-zone img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.reminder-note {
  margin-top: 18px; font-size: 12px; color: var(--ink-faint);
  display: flex; gap: 7px; align-items: flex-start; line-height: 1.6;
}

.overlay-actions {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 14px 18px 18px;
  background: linear-gradient(to top, var(--shell) 60%, transparent);
  display: flex; gap: 10px;
}
.reject-btn {
  flex: 1; background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
  font-family: inherit; font-weight: 700; font-size: 14px; padding: 13px; border-radius: 12px; cursor: pointer;
}
.reject-btn:hover { border-color: var(--danger); color: var(--danger); }
.approve-btn {
  flex: 2; background: linear-gradient(135deg, #FFA275, var(--accent)); color: var(--accent-ink);
  border: none; font-family: inherit; font-weight: 700; font-size: 14px; padding: 13px; border-radius: 12px; cursor: pointer;
}
.approve-btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: sticky; bottom: 0;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--shell);
  flex-shrink: 0;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}
.nav-btn {
  flex: 1; background: none; border: none; font-family: inherit;
  padding: 11px 4px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; color: var(--ink-faint); position: relative;
}
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn span { font-size: 10.5px; letter-spacing: .02em; }
.nav-btn.active { color: var(--accent); }
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 20px);
  background: var(--accent); color: var(--accent-ink);
  font-size: 9.5px; font-weight: 700; min-width: 15px; height: 15px;
  border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

.toast {
  position: fixed; bottom: 78px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--shell);
  font-size: 12.5px; padding: 10px 16px; border-radius: 999px;
  white-space: nowrap; opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none; z-index: 60;
  box-shadow: 0 12px 24px -8px rgba(0,0,0,.4);
  max-width: 90%;
  overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .overlay, .toast { transition: none; }
}
