/* Lingraphica Talk — Phrase Builder
   Palette sampled from reference screenshots. */

:root {
  /* Talk palette */
  --teal-700: #1F6F73;      /* active Talk tab, folder cap */
  --teal-600: #4FB0B0;      /* Good Morning banner */
  --teal-050: #E8F5F5;

  --navy-900: #0E2A3A;      /* dark nav / tab label */
  --navy-800: #13354A;
  --slate-600: #4A5562;
  --slate-500: #6B7380;
  --slate-400: #9AA2AE;
  --slate-300: #C9CED6;
  --slate-200: #E2E5EA;
  --slate-100: #EFF1F4;
  --slate-050: #F6F7F9;

  --mint-bar:  #E5F2D5;     /* left action rail background */
  --amber-btn: #F6CF88;     /* action rail button fills */
  --amber-btn-b:#E4A656;    /* action rail outline */
  --amber-ink: #5A3D0F;

  --yellow-draw:#F7D54C;
  --yellow-crumb:#C99A00;   /* breadcrumb "Start" */

  --blue-primary:#0F5E9C;   /* design-system primary */
  --blue-primary-ink:#0B4A7B;
  --blue-chip:#DCE9F4;
  --blue-chip-border:#AEC7DD;

  --red-500: #D63D3D;
  --red-400: #E56A6A;
  --red-050: #FBE6E6;

  --ink-900: #0E2A3A;
  --ink-700: #2A3C4B;

  --card-bg: #FFFFFF;
  --card-border: #C6CBD2;
  --card-shadow: 0 1px 0 rgba(14,42,58,0.04), 0 1px 2px rgba(14,42,58,0.08);

  --status-bg: #DADDE2;
  --page-bg:   #FFFFFF;

  --radius-card: 8px;
  --radius-btn: 10px;

  --font: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #0b1115;
  font-family: var(--font);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100%;
}

#root { height: 100vh; }

/* ───── Tablet frame + scale wrapper ───── */
.stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1a2430 0%, #0b1115 70%);
  overflow: hidden;
}

.tablet-outer {
  position: relative;
  flex-shrink: 0;
}
.tablet-wrap {
  position: absolute;
  top: 0; left: 0;
  transform-origin: top left;
}

.tablet {
  width: 1280px; height: 860px;
  background: #0a0a0a;
  border-radius: 28px;
  padding: 16px;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  position: relative;
}

.tablet::after {
  /* Front-facing camera dot */
  content: '';
  position: absolute;
  top: 10px; left: 50%;
  width: 6px; height: 6px;
  background: #2a2a2a;
  border-radius: 50%;
  transform: translateX(-50%);
}

.screen {
  width: 100%; height: 100%;
  background: var(--page-bg);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ───── Status bar / tab bar ───── */
.statusbar {
  display: flex; align-items: stretch;
  background: var(--status-bg);
  height: 48px;
  padding-right: 12px;
  flex-shrink: 0;
}

.tab {
  display: flex; align-items: center; gap: 10px;
  padding: 0 22px;
  height: 100%;
  font-weight: 700;
  font-size: 18px;
  color: #0E2A3A;
  cursor: pointer;
  position: relative;
  border-right: 1px solid rgba(14,42,58,0.08);
}
.tab--home { background: var(--navy-900); color: #fff; }
.tab--talk { background: var(--teal-700); color: #fff; }
.tab--draw { background: var(--yellow-draw); color: var(--ink-900); }
.tab--active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 0;
}

.tab svg { flex-shrink: 0; }

.status-meta {
  margin-left: auto;
  display: flex; align-items: center; gap: 18px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-900);
  padding-left: 20px;
}
.status-meta .icon-btn {
  width: 34px; height: 34px;
  background: #fff;
  border-radius: 6px;
  display: grid; place-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  cursor: pointer;
}
.status-meta .menu-btn {
  width: 38px; height: 38px;
  background: var(--teal-700);
  border-radius: 8px;
  display: grid; place-items: center;
}

/* ───── Main layout ───── */
.talk-body {
  flex: 1; display: flex;
  min-height: 0;
  background: #fff;
}

/* Left action rail */
.rail {
  width: 108px;
  background: var(--mint-bar);
  padding: 14px 12px 14px;
  display: flex; flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  border-right: 1px solid #d5e0b8;
}

.rail-btn {
  background: var(--amber-btn);
  border: 2px solid var(--amber-btn-b);
  border-radius: 12px;
  padding: 10px 4px 8px;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--amber-ink);
  cursor: pointer;
  user-select: none;
  transition: transform 120ms, box-shadow 120ms;
}
.rail-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(90,61,15,0.15); }
.rail-btn:active { transform: translateY(0); background: #E4B968; }
.rail-btn .i { display: block; margin-bottom: 4px; height: 28px; }
.rail-btn .i svg { width: 28px; height: 28px; }

.rail-spacer { flex: 1; }
.rail-page {
  text-align: center;
  font-size: 13px;
  color: var(--ink-700);
  margin-bottom: 4px;
}
.rail-pager {
  display: flex; justify-content: space-between;
  gap: 8px;
}
.rail-pager button {
  flex: 1;
  background: #E8EEF3;
  border: 1px solid #C9D3DC;
  border-radius: 999px;
  height: 38px;
  display: grid; place-items: center;
  cursor: pointer;
}

/* Right column */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 14px 20px 16px;
  gap: 10px;
}

.breadcrumb-row {
  display: flex; align-items: center; justify-content: space-between;
}
.breadcrumb {
  color: var(--yellow-crumb);
  font-size: 18px;
  font-weight: 700;
}
.breadcrumb .sep { color: var(--slate-400); margin: 0 6px; }
.breadcrumb .leaf { color: var(--slate-600); font-weight: 600; }
.lang {
  display: flex; align-items: center; gap: 8px;
  font-style: italic; color: var(--ink-900); font-weight: 600;
}

/* ───── Message window ───── */
.msg-window {
  background: #F6F8FA;
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  min-height: 88px;
  padding: 12px 12px 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 200ms, border-color 200ms;
}
.msg-window.speaking {
  background: #E6F3F3;
  border-color: var(--teal-600);
}

.chips {
  flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 12px 6px 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-900);
  cursor: pointer;
  animation: chipIn 180ms ease-out both;
  line-height: 1;
  min-height: 56px;
}
.chip .chip-img {
  width: 36px; height: 36px;
  background: #F6F1E7;
  border-radius: 6px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.chip .chip-img svg { width: 28px; height: 28px; }
.chip .chip-x {
  margin-left: 6px;
  color: var(--slate-400);
  font-size: 14px;
  font-weight: 800;
}
.chip.speaking {
  background: var(--teal-050);
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(79,176,176,0.3);
  transform: translateY(-2px);
}
.chip.func { background: #F0F4F8; }
.chip-placeholder {
  color: var(--slate-400);
  font-size: 19px;
  font-style: italic;
  font-weight: 600;
  padding: 6px 4px;
}
@keyframes chipIn {
  from { opacity: 0; transform: translateY(8px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.msg-actions {
  display: flex; gap: 8px;
  flex-shrink: 0;
}
.msg-action {
  height: 56px;
  min-width: 56px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1.5px solid var(--card-border);
  background: #fff;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-700);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 120ms, transform 80ms;
}
.msg-action:hover { background: var(--slate-050); }
.msg-action:active { transform: scale(0.97); }
.msg-action:disabled { opacity: 0.4; cursor: not-allowed; }
.msg-action.primary {
  background: var(--teal-700);
  color: #fff;
  border-color: var(--teal-700);
  padding: 0 18px;
  font-size: 16px;
}
.msg-action.primary:hover { background: #195c5f; }
.msg-action.danger {
  background: var(--red-050);
  color: var(--red-500);
  border-color: var(--red-400);
}

/* ───── Adaptive row ───── */
.adaptive {
  border: 1.5px dashed #B8D6D7;
  background: #F3FAFA;
  border-radius: 12px;
  padding: 8px 10px 10px;
}
.adaptive-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 6px;
}
.adaptive-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-700);
}
.adaptive-toggle {
  display: flex; gap: 2px;
  background: #fff;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #C6D8DA;
}
.adaptive-toggle button {
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.adaptive-toggle button.on {
  background: var(--teal-700);
  color: #fff;
}

.adaptive-scroll {
  display: flex; gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scroll-behavior: smooth;
}
.adaptive-scroll::-webkit-scrollbar { height: 8px; }
.adaptive-scroll::-webkit-scrollbar-thumb { background: #B8D6D7; border-radius: 4px; }

.mini-card {
  flex: 0 0 auto;
  width: 116px; height: 92px;
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-card);
  display: flex; flex-direction: column;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform 120ms, box-shadow 120ms;
}
.mini-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(14,42,58,0.1); }
.mini-card:active { transform: translateY(0); }
.mini-card .mini-art {
  flex: 1;
  display: grid; place-items: center;
  padding: 4px;
}
.mini-card .mini-art svg { width: 42px; height: 42px; }
.mini-card .mini-label {
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-900);
  text-align: center;
  padding: 3px 4px 5px;
  border-top: 1px solid var(--slate-100);
}
.mini-card .pred-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--teal-700);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ───── Grid ───── */
.grid-wrap { flex: 1; min-height: 0; position: relative; }
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
}
.grid.horiz {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 30px) / 4);
  grid-template-rows: repeat(2, 1fr);
  overflow-x: auto;
  overflow-y: hidden;
}
.grid::-webkit-scrollbar { width: 8px; height: 8px; }
.grid::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 4px; }

.card {
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-card);
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  min-height: 0;
  position: relative;
  transition: transform 120ms, box-shadow 120ms, border-color 120ms;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(14,42,58,0.12); border-color: var(--slate-400); }
.card:active { transform: translateY(0); }

.card.is-folder::before {
  content: '';
  display: block;
  position: absolute;
  top: -1.5px; left: 20%; right: 20%;
  height: 12px;
  background: var(--teal-700);
  border-radius: 6px 6px 0 0;
}

.card-art {
  flex: 1;
  display: grid; place-items: center;
  padding: 8px;
  background: #fff;
  min-height: 0;
}
.card-art svg { max-width: 92%; max-height: 92%; width: 100px; height: 100px; }
.card-art img { max-width: 100%; max-height: 100%; object-fit: cover; border-radius: 4px; }

.card-label {
  background: var(--teal-700);
  color: #fff;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  padding: 6px 8px;
}
.card.is-word .card-label {
  background: #fff;
  color: var(--ink-900);
  border-top: 1.5px solid var(--slate-200);
}

.card.highlight-new {
  animation: cardPop 320ms ease-out;
}
@keyframes cardPop {
  0%   { box-shadow: 0 0 0 0 rgba(79,176,176,0.6); }
  60%  { box-shadow: 0 0 0 6px rgba(79,176,176,0.0); }
  100% { box-shadow: 0 0 0 0 rgba(79,176,176,0); }
}

/* Folder floats-up animation */
.card.just-floated {
  animation: floatUp 360ms cubic-bezier(0.2, 0.8, 0.2, 1.1);
}
@keyframes floatUp {
  0%   { transform: translateY(10px) scale(0.96); opacity: 0.4; }
  60%  { transform: translateY(-2px) scale(1.02); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Inline expansion — folder 'blooms' open within grid */
.folder-bloom {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #EAF6F6 0%, #F3FAFA 100%);
  border: 1.5px solid var(--teal-600);
  border-radius: 10px;
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 8px;
  animation: bloomIn 240ms ease-out;
}
@keyframes bloomIn {
  from { opacity: 0; transform: scaleY(0.96); transform-origin: top; }
  to   { opacity: 1; transform: scaleY(1); }
}
.bloom-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 800;
  font-size: 14px;
  color: var(--teal-700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.bloom-close {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-700);
}
.bloom-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* ───── Tweaks panel ───── */
.tweaks {
  position: fixed;
  right: 20px; bottom: 20px;
  width: 280px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  overflow: hidden;
  z-index: 100;
  font-size: 13px;
}
.tweaks-head {
  background: var(--navy-900);
  color: #fff;
  padding: 10px 14px;
  font-weight: 800;
  display: flex; justify-content: space-between; align-items: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}
.tweaks-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-group label {
  display: block;
  font-weight: 700; color: var(--ink-700);
  margin-bottom: 6px;
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tweak-opts { display: flex; gap: 4px; background: var(--slate-100); padding: 3px; border-radius: 8px; }
.tweak-opts button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-500);
  cursor: pointer;
}
.tweak-opts button.on {
  background: #fff;
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ───── Hint toast ───── */
.hint {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: rgba(14,42,58,0.92);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  z-index: 10;
  animation: hintIn 200ms ease-out;
  pointer-events: none;
}
@keyframes hintIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
