/* ── Shared styles for Japanese Reading app ── */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #111318;
  --card: #1c1f27;
  --card2: #22262f;
  --accent: #4ade80;
  --accent-dim: rgba(74,222,128,0.15);
  --text-ja: #f0f0f0;
  --text-zh: #8a9ab5;
  --text-meta: #4a5568;
  --border: rgba(255,255,255,0.07);
}

body {
  font-family: 'Hiragino Sans', 'Yu Gothic', 'Noto Sans JP', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text-ja);
  min-height: 100vh;
  -webkit-touch-callout: none;
}

/* ── Site nav ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(17,19,24,0.96);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 50px;
  gap: 4px;
}
.nav-logo {
  font-size: 18px;
  margin-right: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-link {
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  position: relative;
}
.nav-link:hover { color: var(--text-ja); background: var(--card); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }
.nav-badge {
  display: none;
  background: var(--accent);
  color: #0a0e14;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: middle;
  text-align: center;
}
.nav-badge.has-items { display: inline-block; }

/* ── Sheet (bottom panel) ── */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet-panel {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #1c1f27;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid rgba(255,255,255,0.09);
  max-height: 85vh; overflow-y: auto;
  z-index: 1200;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
  padding-bottom: 40px;
  overscroll-behavior: contain;
}
.sheet-panel.open { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px; margin: 12px auto 16px;
}
.sheet-header {
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
}
.sheet-header-title { font-size: 16px; font-weight: 600; color: var(--text-ja); }
.sheet-header-sub { font-size: 12px; color: var(--text-meta); margin-top: 3px; }

/* ── Analysis sheet items ── */
.sheet-section { padding: 14px 20px 0; }
.sheet-section-title {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-meta); margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.vocab-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 11px;
}
.vocab-item-main { flex: 1; min-width: 0; }
.vocab-surface { font-size: 16px; font-weight: 600; color: var(--text-ja); }
.vocab-reading { font-size: 11px; color: #6ee7a0; margin-left: 7px; }
.vocab-pos {
  font-size: 10px; color: var(--text-meta);
  background: rgba(255,255,255,0.05); border-radius: 4px;
  padding: 1px 5px; margin-left: 5px;
}
.vocab-meaning { font-size: 13px; color: var(--text-zh); margin-top: 3px; }
.vocab-meaning.dim { color: var(--text-meta); font-style: italic; }
.grammar-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px;
  margin-bottom: 8px; display: flex; gap: 11px; align-items: flex-start;
}
.grammar-item-main { flex: 1; min-width: 0; }
.grammar-pattern { font-size: 15px; font-weight: 600; color: #93c5fd; }
.grammar-level {
  font-size: 10px; background: rgba(147,197,253,0.15); color: #93c5fd;
  border-radius: 4px; padding: 1px 6px; margin-left: 7px;
}
.grammar-meaning { font-size: 13px; color: var(--text-zh); margin-top: 3px; }
.grammar-example { font-size: 12px; color: var(--text-meta); margin-top: 2px; }
.grammar-example::before { content: '例: '; }
.review-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-meta); font-size: 14px; font-weight: 600;
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.review-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.review-btn.saved { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* ── Sheet loading / empty states ── */
.sheet-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 9px; padding: 36px 20px; color: var(--text-meta); font-size: 13px;
}
.sheet-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.sheet-empty {
  text-align: center; padding: 32px 20px;
  color: var(--text-meta); font-size: 13px; line-height: 1.7;
}

/* ── Toast ── */
#toast {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--accent);
  color: #111;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 2000;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
