/* Realtime JP-CN Translator — Pencil / sketch theme.
   Colors and typography mirror docs/design/*.svg. */

@import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&family=Kalam:wght@400;700&family=Noto+Sans+SC:wght@400;700&family=Noto+Sans+JP:wght@400;700&display=swap');

:root {
  --paper: #FDFBF4;
  --ink: #2B2B2B;
  --ink-soft: #6E6E6E;
  --accent: #E63946;
  --green: #2BB36C;
  --yellow: #FFE066;
  --shadow: 6px 6px 0 var(--ink);
  --hand: 'Patrick Hand', 'Kalam', 'Noto Sans SC', 'Noto Sans JP', cursive;
  --ja: 'Noto Sans JP', 'Patrick Hand', sans-serif;
  --zh: 'Noto Sans SC', 'Patrick Hand', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  padding: 20px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- Sketch surfaces ---- */
.card {
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  position: relative;
  box-shadow: var(--shadow);
}
.card::after { /* subtle paper grain via repeating dots */
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(43,43,43,0.04) 1px, transparent 1px);
  background-size: 6px 6px;
  pointer-events: none;
  border-radius: inherit;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 20px;
}
.app-title { font-size: 28px; font-weight: 700; }
.app-back  { font-size: 26px; font-weight: 700; padding: 4px 8px; }
.notebook-link {
  display: inline-flex; flex-direction: column; align-items: center;
  gap: 4px; font-size: 13px; color: var(--ink-soft);
}
.notebook-icon {
  width: 48px; height: 38px; border: 2.2px solid var(--ink);
  background: var(--paper); position: relative;
  box-shadow: 4px 4px 0 var(--ink);
}
.notebook-icon::before, .notebook-icon::after, .notebook-icon span {
  content: ''; position: absolute; left: 6px; right: 6px;
  border-top: 2px solid var(--ink);
}
.notebook-icon::before { top: 10px; }
.notebook-icon::after  { top: 19px; }
.notebook-icon span    { top: 28px; right: 14px; display: block; }

.section-title { font-size: 19px; margin: 24px 0 14px; }
.subtitle { font-size: 19px; margin: 0 0 16px; color: var(--ink); }
.dashed-divider { border: 0; border-top: 1.5px dashed var(--ink-soft); margin: 24px 4px; }

/* ---- Big language buttons ---- */
.lang-button {
  display: block;
  width: 100%;
  padding: 26px 20px;
  margin: 18px 0;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  box-shadow: var(--shadow);
  text-align: center;
  font-family: var(--hand);
  transition: transform 0.05s, box-shadow 0.05s;
}
.lang-button .main { font-size: 32px; font-weight: 700; display: block; }
.lang-button .main.ja { font-family: var(--ja); }
.lang-button .main.zh { font-family: var(--zh); }
.lang-button .sub  { font-size: 17px; color: var(--ink-soft); display: block; margin-top: 6px; }
.lang-button:active { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }

/* ---- Recent conversation cards ---- */
.recent-card {
  display: block;
  padding: 14px 18px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  box-shadow: var(--shadow);
  margin: 14px 4px;
}
.recent-card:nth-child(odd)  { transform: rotate(-1.2deg); }
.recent-card:nth-child(even) { transform: rotate(1deg); }
.recent-card .meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.recent-card .preview { font-size: 17px; }

.view-all {
  display: block; text-align: center; margin-top: 20px;
  font-size: 17px;
}
.view-all u { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* ---- Session (live translating) ---- */
.session-status {
  display: flex; align-items: center; gap: 10px; margin-bottom: 22px;
}
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ink-soft); }
.dot.live { background: var(--green); animation: pulse 1.4s infinite; }
.dot.error { background: var(--accent); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.status-label { font-size: 22px; font-weight: 700; }
.status-dir   { margin-left: auto; font-size: 16px; color: var(--ink-soft); }

.label { font-size: 16px; color: var(--ink-soft); margin: 4px 0 6px 4px; }
.bubble {
  padding: 18px 18px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  box-shadow: var(--shadow);
  min-height: 80px;
  word-break: break-word;
  white-space: pre-wrap;
}
.bubble.source { font-size: 19px; color: var(--ink-soft); margin-bottom: 22px; min-height: 100px; }
.bubble.target { font-size: 32px; font-weight: 700; line-height: 1.32; min-height: 200px; }
.bubble.target.ja { font-family: var(--ja); }
.bubble.target.zh { font-family: var(--zh); }
.bubble .partial { color: var(--ink-soft); }

.session-actions {
  display: flex; justify-content: center; margin: 30px 0 8px;
  gap: 14px;
}
.btn-stop {
  background: var(--accent); color: var(--paper);
  border: 2.2px solid var(--ink); border-radius: 4px;
  font-family: var(--hand);
  font-size: 26px; font-weight: 700;
  padding: 14px 32px;
  box-shadow: var(--shadow);
}
.btn-stop:active { transform: translate(3px,3px); box-shadow: 3px 3px 0 var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 4px;
  font-size: 16px;
  box-shadow: 4px 4px 0 var(--ink-soft);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; }

/* ---- History list ---- */
.search-box {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--hand);
  font-size: 17px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  margin: 10px 0 24px;
  color: var(--ink);
}
.search-box::placeholder { color: var(--ink-soft); }
.date-sticker {
  display: inline-block;
  padding: 4px 18px; font-weight: 700; font-size: 17px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  margin: 22px 0 14px;
  transform: rotate(-2deg);
}
.history-card {
  display: block; padding: 14px 18px;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.history-card:nth-child(odd)  { transform: rotate(-0.8deg); }
.history-card:nth-child(even) { transform: rotate(0.8deg); }
.history-card .meta { font-size: 13px; color: var(--ink-soft); }
.history-card .preview { font-size: 18px; margin: 8px 0; }
.history-card hr { border: 0; border-top: 1px dashed var(--ink-soft); margin: 6px 0; }

/* ---- Detail (turns list) ---- */
.session-meta { color: var(--ink-soft); font-size: 14px; margin: 0 0 14px; }
.wavy-divider { color: var(--ink); font-size: 14px; letter-spacing: 4px; margin: 6px 0 18px; }
.turn { margin-bottom: 22px; }
.turn .ts { font-size: 13px; color: var(--ink-soft); }
.turn .src, .turn .tgt {
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  padding: 12px 14px;
  margin-top: 6px;
}
.turn .src { font-size: 15px; color: var(--ink-soft); }
.turn .tgt { font-size: 22px; font-weight: 700; box-shadow: var(--shadow); margin: 14px 0 0; }
.turn .arrow { text-align: center; margin: 6px 0; color: var(--ink-soft); font-size: 20px; }

.detail-actions {
  position: sticky; bottom: 0; left: 0; right: 0;
  display: flex; gap: 14px; justify-content: space-between;
  padding: 14px 0;
  background: var(--paper);
  border-top: 2.2px solid var(--ink);
  margin-top: 30px;
}
.detail-actions .act {
  flex: 1; padding: 12px 0;
  background: var(--paper);
  border: 2.2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--ink);
  font-family: var(--hand);
  font-size: 14px;
  text-align: center;
}
.detail-actions .act .ico { display: block; font-size: 20px; }

/* ---- Misc ---- */
.empty-state {
  text-align: center; color: var(--ink-soft); padding: 40px 0;
}
.error-banner {
  border: 2.2px solid var(--accent);
  background: #FDECEC;
  padding: 12px 14px;
  border-radius: 4px;
  margin: 14px 0;
  color: var(--ink);
}
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

@media (prefers-color-scheme: dark) {
  :root {
    /* Keep paper feel even in dark mode (unchanged) */
  }
}
