/* ============================================================
   LINE Flex Wireframes — App Shell
   ============================================================ */

:root {
  --app-bg: #1a1c20;
  --panel-bg: #23262d;
  --panel-bg-2: #1e2026;
  --panel-fg: #e8e8e8;
  --panel-fg-dim: #9aa0a8;
  --panel-fg-mute: #6b7280;
  --panel-border: #2e323a;
  --panel-accent: var(--primary, #ffa73b);
  --chip-bg: #2a2e36;
  --chip-bg-active: var(--primary, #ffa73b);
  --chip-fg-active: #1a1c20;

  /* LINE chat colors */
  --line-bg: #8aacd2;          /* default LINE chat wallpaper-ish */
  --line-user: #8be08b;        /* user bubble green */
  --line-bot: #ffffff;         /* bot bubble white */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--app-bg);
  color: var(--panel-fg);
  font-family: var(--font-sans);
  font-size: 14px;
  height: 100%;
  overflow: hidden;
}

#root { height: 100vh; }

/* ---------- App grid ---------- */
.app {
  display: grid;
  grid-template-columns: 280px 1fr 460px;
  grid-template-rows: 48px 1fr;
  grid-template-areas:
    "topbar topbar topbar"
    "nav    stage  spec";
  height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--panel-bg-2);
  border-bottom: 1px solid var(--panel-border);
}
.topbar__title { font-size: 13px; font-weight: 500; letter-spacing: 0.02em; }
.topbar__title .accent { color: var(--panel-accent); }
.topbar__meta { font-size: 12px; color: var(--panel-fg-dim); }
.topbar__right { margin-left: auto; display: flex; gap: 6px; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--panel-fg);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { background: var(--chip-bg); }
.btn-ghost.is-active { background: var(--chip-bg-active); color: var(--chip-fg-active); border-color: transparent; }

/* ---------- Left nav ---------- */
.nav {
  grid-area: nav;
  background: var(--panel-bg-2);
  border-right: 1px solid var(--panel-border);
  overflow-y: auto;
  padding: 12px 0;
}
.nav__group-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--panel-fg-mute);
  padding: 14px 16px 6px;
  text-transform: uppercase;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--panel-fg);
  border-left: 2px solid transparent;
  user-select: none;
}
.nav__item:hover { background: rgba(255,255,255,0.03); }
.nav__item.is-active {
  background: rgba(255,167,59,0.10);
  color: var(--panel-accent);
  border-left-color: var(--panel-accent);
}
.nav__item-num {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--chip-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--panel-fg-dim);
  flex-shrink: 0;
}
.nav__item.is-active .nav__item-num { background: var(--panel-accent); color: var(--chip-fg-active); }
.nav__item-label { flex: 1; min-width: 0; }
.nav__item-label-zh { display: block; font-weight: 500; }
.nav__item-label-en { display: block; font-size: 11px; color: var(--panel-fg-dim); margin-top: 1px; }

/* ---------- Stage ---------- */
.stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--app-bg);
}
.stage__head {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-bg-2);
}
.stage__crumbs {
  font-size: 11px;
  color: var(--panel-fg-mute);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stage__title {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
}
.stage__prompt {
  font-size: 12px;
  color: var(--panel-fg-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.stage__prompt::before { content: '"'; }
.stage__prompt::after { content: '"'; }

.state-tabs {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.state-tab {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--panel-fg-dim);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.state-tab:hover { color: var(--panel-fg); }
.state-tab.is-active {
  background: var(--panel-accent);
  color: var(--chip-fg-active);
  border-color: transparent;
  font-weight: 500;
}
.state-tab__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--panel-fg-mute);
}
.state-tab.is-active .state-tab__dot { background: var(--chip-fg-active); }
.state-tab--happy .state-tab__dot { background: #50c59b; }
.state-tab--empty .state-tab__dot { background: #9aa0a8; }
.state-tab--single .state-tab__dot { background: #59abeb; }
.state-tab--multi .state-tab__dot { background: #b38fec; }
.state-tab--overflow .state-tab__dot { background: #ffa73b; }
.state-tab--error .state-tab__dot { background: #fa5b5b; }
.state-tab--ambiguous .state-tab__dot { background: #f88f88; }

.stage__body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 28px 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,167,59,0.04), transparent 60%),
    var(--app-bg);
}

/* ---------- View mode toggle ---------- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
}
.view-toggle button {
  background: transparent;
  border: none;
  color: var(--panel-fg-dim);
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.view-toggle button.is-active { background: var(--chip-bg); color: var(--panel-fg); }

/* ---------- Spec panel ---------- */
.spec {
  grid-area: spec;
  background: var(--panel-bg-2);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.spec__tabs {
  display: flex;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel-bg);
}
.spec__tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--panel-fg-dim);
  padding: 10px 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
}
.spec__tab.is-active {
  color: var(--panel-fg);
  border-bottom-color: var(--panel-accent);
  background: var(--panel-bg-2);
}
.spec__body {
  flex: 1;
  overflow: auto;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
}

/* Tree view */
.tree-line { white-space: pre; color: var(--panel-fg); }
.tree-line .t-type { color: #ffc072; }
.tree-line .t-key { color: #95c9f2; }
.tree-line .t-val { color: #8fdabf; }
.tree-line .t-action { color: #ceb8f3; }
.tree-line .t-comment { color: var(--panel-fg-mute); }

/* JSON view */
.json-block { white-space: pre; color: var(--panel-fg); }
.json-block .j-key { color: #95c9f2; }
.json-block .j-str { color: #8fdabf; }
.json-block .j-num { color: #ffc072; }
.json-block .j-bool { color: #ceb8f3; }
.json-block .j-null { color: #fa8e8e; }

.spec__section { margin-bottom: 22px; }
.spec__section h4 {
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--panel-fg-mute);
  margin: 0 0 8px;
  font-weight: 600;
}

.spec__note {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--panel-fg-dim);
  line-height: 1.55;
  background: rgba(255,167,59,0.06);
  border-left: 2px solid var(--panel-accent);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.spec__note strong { color: var(--panel-fg); font-weight: 500; }

.spec__edge {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  font-family: var(--font-sans);
  font-size: 12px;
}
.spec__edge dt { color: var(--panel-fg-dim); }
.spec__edge dd { margin: 0; color: var(--panel-fg); }

.spec__pill {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: var(--chip-bg);
  padding: 1px 6px;
  border-radius: 3px;
  color: #ffc072;
}

.tok {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: var(--chip-bg);
  padding: 0px 5px;
  border-radius: 3px;
  color: #95c9f2;
}

/* ---------- LINE chat frame ---------- */
.chat-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.iphone {
  width: 390px;
  flex-shrink: 0;
  background: #000;
  border-radius: 44px;
  padding: 10px;
  box-shadow:
    0 0 0 1.5px #2a2a2a,
    0 20px 60px rgba(0,0,0,0.5);
  position: relative;
}
.iphone__screen {
  background: #b3c4d8;   /* LINE default chat bg-ish blue */
  border-radius: 36px;
  overflow: hidden;
  height: 770px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.iphone__notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 30px;
  background: #000;
  border-radius: 20px;
  z-index: 10;
}

.line-status {
  height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 28px 8px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  font-family: -apple-system, sans-serif;
}
.line-status__right { display: flex; align-items: center; gap: 5px; }

.line-header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.line-header__back {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--neutral-20);
}
.line-header__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffa73b 0%, #ff8e03 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-sans);
}
.line-header__name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--neutral-10);
}
.line-header__name-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--neutral-40);
}
.line-header__actions {
  display: flex;
  gap: 14px;
  color: var(--neutral-20);
}

.line-thread {
  flex: 1;
  overflow-y: auto;
  background: #b3c4d8;
  padding: 14px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.line-msg {
  display: flex;
  max-width: 100%;
}
.line-msg--user {
  justify-content: flex-end;
}
.line-msg--bot {
  justify-content: flex-start;
  align-items: flex-end;
  gap: 6px;
}
.line-msg__avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffa73b 0%, #ff8e03 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  font-family: var(--font-sans);
}
.line-msg__name {
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  margin: 0 0 2px 4px;
  font-weight: 500;
}
.line-msg__col { display: flex; flex-direction: column; max-width: 86%; min-width: 0; }

.line-bubble--user {
  background: var(--line-user);
  padding: 8px 12px;
  border-radius: 18px 4px 18px 18px;
  font-size: 14px;
  color: #111;
  line-height: 1.4;
  max-width: 280px;
}

.line-time {
  font-size: 9px;
  color: rgba(255,255,255,0.85);
  align-self: flex-end;
  margin: 0 4px 2px;
  font-weight: 500;
}
.line-msg--bot .line-time { order: 2; align-self: flex-end; margin-bottom: 2px; }

.line-input {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #ffffff;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 8px 12px 22px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--neutral-40);
}
.line-input__field {
  flex: 1;
  background: #f1f1f1;
  border-radius: 18px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--neutral-50);
}
.line-input__icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--neutral-40);
}

/* ---------- Bare bubble mode ---------- */
.bare-stage {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.bare-stage__prompt {
  font-size: 12px;
  color: var(--panel-fg-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-bg);
  padding: 7px 12px;
  border-radius: 4px;
  border-left: 2px solid var(--primary);
}

.bare-carousel {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  overflow-x: auto;
  padding: 8px 4px;
  max-width: 100%;
}

/* ---------- Source code blocks ---------- */
.code-actions { display: flex; gap: 6px; margin-bottom: 8px; }

/* Scrollbars (subtle) */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #3a3e47; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #4a4e57; }

/* Fill peek effect for carousel overflow */
.peek-shadow {
  width: 30px;
  flex-shrink: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.0), rgba(0,0,0,0.15));
  margin-left: -30px;
  position: relative;
  z-index: 1;
  border-radius: 0 8px 8px 0;
}
