/* hogushi-cms admin shell — warm, calm, mobile-first.
 * Palette echoes theme/style.css (Linen / editorial-warm, brand green hue 145–148).
 * Big thumb-reachable tap targets, no wireframe feel. */

:root {
  --paper:    oklch(97% 0.012 90);
  --paper-2:  oklch(94.5% 0.013 90);
  --paper-3:  oklch(99% 0.010 90);
  --card:     #ffffff;
  --rule:     oklch(88% 0.010 90);
  --rule-2:   oklch(80% 0.010 90);
  --muted:    oklch(50% 0.010 80);
  --ink-2:    oklch(36% 0.012 60);
  --ink:      oklch(22% 0.012 60);
  --accent:        oklch(72% 0.205 148);
  --accent-soft:   oklch(94% 0.055 148);
  --accent-softer: oklch(97% 0.030 148);
  --line:     oklch(72% 0.180 145);   /* LINE green */
  --line-strong: oklch(64% 0.175 145);
  --draft:    oklch(75% 0.010 90);

  --font-display: "Fraunces", "Hiragino Mincho ProN", serif;
  --font-ui: "Newsreader", "Hiragino Sans", system-ui, sans-serif;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --pill: 999px;
  --shadow-1: 0 1px 2px oklch(50% 0.02 90 / 0.06), 0 4px 14px oklch(50% 0.02 90 / 0.06);
  --shadow-2: 0 6px 30px oklch(40% 0.02 90 / 0.14);
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; position: relative; overflow-x: clip; }
body { overflow-x: clip; }

/* ── Screens ─────────────────────────────────────────── */
.screen { display: none; animation: fade 0.22s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px calc(14px);
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  background: oklch(97% 0.012 90 / 0.86);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.topbar__title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iconbtn {
  height: var(--tap); min-width: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule); background: var(--card);
  border-radius: var(--pill); color: var(--ink);
  font-size: 15px; font-weight: 600; padding: 0 16px;
  transition: background 0.16s, transform 0.09s;
}
.iconbtn:active { transform: scale(0.96); background: var(--paper-2); }
.iconbtn--ghost { border-color: transparent; background: transparent; padding: 0 10px; font-size: 22px; }
.iconbtn--pub { background: var(--line); color: #fff; border-color: transparent; }
.iconbtn--pub:active { background: var(--line-strong); }

/* ── Dashboard ───────────────────────────────────────── */
.dash-head { padding: 26px 20px 8px; }
.dash-head h1 {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 30px; letter-spacing: -0.02em; margin: 0 0 6px;
}
.dash-head p { color: var(--muted); margin: 0; font-size: 14.5px; }

.page-list { padding: 12px 16px 40px; display: grid; gap: 14px; }

.page-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.page-card__main {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 18px 18px 14px; color: inherit;
}
.page-card__top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 4px 11px; border-radius: var(--pill);
}
.badge--live { background: var(--accent-soft); color: var(--accent); }
.badge--draft { background: var(--paper-2); color: var(--muted); }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--live .dot { background: var(--line); }
.page-card__title {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 22px; letter-spacing: -0.01em; margin: 6px 0 3px; line-height: 1.25;
}
.page-card__meta { color: var(--muted); font-size: 13.5px; }
.page-card__actions {
  display: flex; gap: 8px; padding: 0 14px 14px; flex-wrap: wrap;
  border-top: 1px solid var(--paper-2); margin-top: 2px; padding-top: 12px;
}
.chip {
  flex: 1 1 30%; min-height: 46px; min-width: 0;
  border: 1px solid var(--rule); background: var(--paper-3);
  border-radius: var(--r-sm); color: var(--ink-2);
  font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 0.14s, transform 0.09s; white-space: nowrap;
}
.chip:active { transform: scale(0.97); background: var(--paper-2); }

/* ── Editor ──────────────────────────────────────────── */
#screen-editor.active { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.preview-wrap {
  position: relative;
  flex: 0 0 42vh;
  background: var(--paper-3);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.preview-frame {
  width: 100%; height: 100%; border: 0; display: block; background: var(--paper);
}
.preview-tag {
  position: absolute; top: 10px; left: 12px; z-index: 2;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); background: oklch(99% 0.008 90 / 0.85);
  padding: 4px 9px; border-radius: var(--pill); backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
}
.preview-refresh {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--rule); background: oklch(99% 0.008 90 / 0.9);
  font-size: 17px; display: inline-flex; align-items: center; justify-content: center;
}

.editor-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px 150px;
}
.editor-hint {
  color: var(--muted); font-size: 13px; padding: 2px 4px 12px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Block cards ─────────────────────────────────────── */
.block-card {
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--r-md); box-shadow: var(--shadow-1);
  margin-bottom: 12px; overflow: hidden;
}
.block-card.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer), var(--shadow-1); }
.block-card__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px;
}
.block-card__grip {
  display: flex; flex-direction: column; gap: 5px; padding: 6px 2px;
}
.reorder {
  width: 40px; height: 30px; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--paper-3); color: var(--ink-2);
  font-size: 14px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.reorder:active { background: var(--paper-2); }
.reorder:disabled { opacity: 0.3; }
.block-card__tap {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit;
  padding: 6px 2px; min-height: 44px;
}
.block-card__type {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; color: var(--accent);
  display: flex; align-items: center; gap: 6px; margin-bottom: 2px;
}
.block-card__type .ic {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; border-radius: 6px;
  background: var(--accent-soft); font-size: 12px;
}
.block-card__summary {
  font-size: 15px; color: var(--ink); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.block-card__chev { color: var(--muted); font-size: 15px; padding: 0 6px; transition: transform 0.2s; }
.block-card.open .block-card__chev { transform: rotate(90deg); }

.block-form { padding: 4px 14px 16px; border-top: 1px solid var(--paper-2); }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 6px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: 0.01em;
}
.field input[type=text], .field input[type=url], .field textarea, .field select {
  width: 100%; border: 1px solid var(--rule); background: var(--paper-3);
  border-radius: var(--r-sm); padding: 12px 13px; font-size: 15.5px; color: var(--ink);
  line-height: 1.6; -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; min-height: 76px; }
.field textarea.big { min-height: 150px; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px var(--accent-softer);
}
.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.6' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}

/* list sub-items (faq / links) */
.sublist { display: grid; gap: 10px; }
.subitem {
  border: 1px dashed var(--rule-2); border-radius: var(--r-sm);
  padding: 10px 11px 4px; background: var(--paper-3); position: relative;
}
.subitem__bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.subitem__n { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.subitem__del {
  border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px 6px;
}
.addbtn {
  width: 100%; min-height: 44px; margin-top: 4px;
  border: 1px dashed var(--accent); background: var(--accent-softer);
  color: var(--accent); border-radius: var(--r-sm); font-weight: 600; font-size: 14px;
}
.addbtn:active { background: var(--accent-soft); }

.block-form__foot { display: flex; gap: 8px; margin-top: 12px; }
.danger {
  border: 1px solid oklch(70% 0.14 25 / 0.4); background: oklch(97% 0.03 25);
  color: oklch(52% 0.16 25); border-radius: var(--r-sm); min-height: 44px;
  font-size: 14px; font-weight: 600; padding: 0 16px;
}

/* add-block button at end of list */
.add-block {
  width: 100%; min-height: 52px; margin-top: 6px;
  border: 1px dashed var(--rule-2); background: var(--card);
  color: var(--ink-2); border-radius: var(--r-md); font-weight: 600; font-size: 15px;
}
.add-block:active { background: var(--paper-2); }

/* ── NL edit box (fixed bottom) ──────────────────────── */
.nl-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 640px; margin: 0 auto;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: oklch(97% 0.012 90 / 0.92);
  backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--rule);
}
.nl-explain {
  font-size: 11.5px; color: var(--muted); text-align: center; margin: 0 0 8px; line-height: 1.4;
}
.nl-explain b { color: var(--accent); font-weight: 600; }
.nl-row { display: flex; gap: 8px; align-items: flex-end; }
.nl-row textarea {
  flex: 1; border: 1px solid var(--rule); background: #fff; border-radius: 20px;
  padding: 11px 15px; font-size: 15px; resize: none; max-height: 96px; min-height: 46px; line-height: 1.4;
}
.nl-row textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }
.nl-send {
  min-width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.nl-send:active { background: var(--line-strong); }

/* ── History ─────────────────────────────────────────── */
.hist-list { padding: 14px 16px 60px; display: grid; gap: 12px; }
.hist-item {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: 15px 16px;
  display: flex; align-items: center; gap: 12px;
}
.hist-item.current { border-color: var(--accent); background: var(--accent-softer); }
.hist-main { flex: 1; min-width: 0; }
.hist-ver { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.03em; }
.hist-note { font-size: 15px; color: var(--ink); margin: 2px 0 1px; }
.hist-time { font-size: 12.5px; color: var(--muted); }
.hist-restore {
  border: 1px solid var(--rule); background: var(--paper-3); color: var(--ink-2);
  border-radius: var(--pill); min-height: 40px; padding: 0 16px; font-size: 13.5px; font-weight: 600;
}
.hist-restore:active { background: var(--paper-2); }
.hist-item.current .hist-restore { visibility: hidden; }
.hist-badge {
  font-size: 11px; font-weight: 700; color: var(--line); letter-spacing: 0.04em;
}

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px);
  z-index: 60; background: var(--ink); color: var(--paper-3);
  padding: 13px 22px; border-radius: var(--pill); font-size: 14.5px; font-weight: 600;
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s; max-width: 88%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Sheet (confirm / add menu) ──────────────────────── */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 50; background: oklch(30% 0.02 90 / 0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.sheet-scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 640px; margin: 0 auto;
  background: var(--paper); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px 18px calc(24px + var(--safe-b));
  transform: translateY(102%); transition: transform 0.26s var(--ease, cubic-bezier(0.16,1,0.3,1));
  box-shadow: var(--shadow-2); max-height: 80vh; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--rule-2); margin: 4px auto 14px; }
.sheet h3 { font-family: var(--font-display); font-style: italic; font-size: 20px; margin: 0 0 6px; font-weight: 500; }
.sheet p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.sheet__actions { display: grid; gap: 10px; }
.btn {
  min-height: 52px; border-radius: var(--r-md); font-size: 16px; font-weight: 600;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn--primary { background: var(--line); color: #fff; border-color: transparent; }
.btn--primary:active { background: var(--line-strong); }
.btn:active { transform: scale(0.99); }

.add-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-menu button {
  min-height: 60px; border: 1px solid var(--rule); background: var(--card);
  border-radius: var(--r-md); color: var(--ink); font-size: 14px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.add-menu button:active { background: var(--paper-2); }
.add-menu .ic {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}

@media (min-width: 700px) {
  #screen-editor.active { height: auto; min-height: 100vh; flex-direction: row; }
  .preview-wrap { flex: 1; height: 100vh; position: sticky; top: 0; border-bottom: 0; border-right: 1px solid var(--rule); }
  .editor-col { flex: 1; max-width: 420px; }
}
