@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap');

:root {
  --bg: #f5f0eb;
  --surface: #fffdfb;
  --surface-soft: #f8f1ed;
  --text: #35262b;
  --muted: #89777c;
  --accent: #751b31;
  --accent-dark: #5d1427;
  --accent-soft: #f2e3e6;
  --border: #eadde0;
  --reader-text: #3d3033;
  --shadow: 0 14px 40px rgba(66, 29, 40, .07);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  transition: background .2s, color .2s;
}
body.dark-theme {
  --bg: #1d191c;
  --surface: #292226;
  --surface-soft: #33292e;
  --text: #f2e9e9;
  --muted: #b6a4aa;
  --accent: #c2768b;
  --accent-dark: #a85a72;
  --accent-soft: #49323b;
  --border: #493b41;
  --reader-text: #eee2e5;
  --shadow: 0 14px 40px rgba(0, 0, 0, .18);
}
button, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  height: 68px; padding: 0 max(22px, calc((100% - 1050px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { display:flex; gap:10px; align-items:center; color:var(--text); text-decoration:none; font-weight:700; letter-spacing:.2px; }
.brand-mark { width:31px; height:31px; display:grid; place-items:center; border-radius:10px; background:var(--accent); color:white; font-family:"Playfair Display",serif; font-size:20px; }
.theme-controls { display:flex; gap:7px; }
.icon-button { width:36px; height:36px; border:1px solid var(--border); border-radius:11px; background:var(--surface-soft); color:var(--text); font-size:19px; }
.app-shell { width:min(100% - 32px, 920px); margin:32px auto 24px; }
.welcome-panel {
  min-height:220px; padding:34px 38px; border-radius:22px; background:var(--surface);
  box-shadow:var(--shadow); display:grid; grid-template-columns:1fr auto; align-items:center; gap:18px;
  position:relative; overflow:hidden;
}
.welcome-panel:after { content:""; position:absolute; width:230px; height:230px; right:90px; top:-145px; border:1px solid var(--border); border-radius:50%; pointer-events:none; }
.eyebrow { margin:0 0 10px; color:var(--accent); font-size:10px; font-weight:700; letter-spacing:1.7px; }
h1,h2 { font-family:"Playfair Display",serif; }
h1 { margin:0; font-size:clamp(31px,5vw,46px); line-height:1.08; letter-spacing:-.7px; }
h1 span { color:var(--accent); }
.intro { color:var(--muted); margin:13px 0 0; font-size:14px; }
.upload-button { position:relative; z-index:1; display:flex; align-items:center; gap:10px; background:var(--accent); color:white; padding:14px 19px; border-radius:12px; font-size:14px; font-weight:700; cursor:pointer; box-shadow:0 8px 20px rgba(117,27,49,.18); }
.upload-button:hover,.primary-button:hover { background:var(--accent-dark); }
.upload-icon { font-size:21px; line-height:1; }
.file-name { grid-column:1/-1; margin:-5px 0 0; color:var(--muted); font-size:12px; overflow-wrap:anywhere; }
.reader-panel,.translation-panel { margin-top:20px; padding:26px 30px; border:1px solid var(--border); border-radius:20px; background:var(--surface); box-shadow:var(--shadow); }
.reader-toolbar { display:flex; align-items:end; justify-content:space-between; gap:16px; padding-bottom:19px; border-bottom:1px solid var(--border); }
.chapter-control { display:flex; flex-direction:column; gap:7px; min-width:180px; }
.chapter-control label,.language-field label { color:var(--muted); font-size:10px; font-weight:700; letter-spacing:1.3px; }
select { min-width:0; padding:11px 12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--text); }
select:disabled { opacity:.6; }
.reader-nav,.reader-bottom-nav { display:flex; gap:8px; }
.secondary-button { border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--text); padding:10px 13px; font-size:12px; font-weight:600; }
.secondary-button:disabled { opacity:.4; cursor:not-allowed; }
.book-text { min-height:260px; padding:30px clamp(2px,4vw,34px); color:var(--reader-text); font-family:Georgia,serif; font-size:17px; line-height:1.9; overflow-wrap:anywhere; }
.book-text h1,.book-text h2,.book-text h3 { color:var(--accent); font-family:"Playfair Display",serif; line-height:1.3; }
.book-text p { margin:0 0 1.15em; white-space:pre-wrap; }
.book-text img { max-width:100%; height:auto; }
.empty-state { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:var(--muted); }
.empty-state h2 { margin:8px 0 4px; color:var(--text); font-size:23px; }
.empty-state p { margin:0; font-family:"DM Sans",sans-serif; font-size:13px; }
.empty-icon { color:var(--accent); font-size:25px; }
.reader-bottom-nav { justify-content:space-between; padding-top:15px; border-top:1px solid var(--border); }
.section-heading { display:flex; align-items:center; justify-content:space-between; }
.section-heading h2 { margin:0; font-size:27px; }
.translation-mark { width:43px; height:43px; display:grid; place-items:center; border-radius:14px; background:var(--accent-soft); color:var(--accent); font-size:22px; }
.translation-modes { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin:22px 0 20px; padding:5px; border-radius:12px; background:var(--surface-soft); }
.translation-mode { border:0; border-radius:9px; background:transparent; color:var(--muted); padding:11px 8px; font-size:13px; font-weight:600; }
.translation-mode.active { background:var(--surface); color:var(--accent); box-shadow:0 2px 9px rgba(40,20,25,.07); }
.translation-settings { margin-top:5px; }
.language-selectors { display:grid; grid-template-columns:1fr 38px 1fr; gap:10px; align-items:end; }
.language-field { display:flex; flex-direction:column; gap:7px; min-width:0; }
.language-field select { width:100%; padding:12px 9px; font-size:13px; }
.swap-button { height:42px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--accent); font-size:21px; }
.primary-button { width:100%; margin-top:16px; padding:14px; border:0; border-radius:11px; background:var(--accent); color:white; font-size:14px; font-weight:700; }
.status { min-height:18px; margin:12px 0; color:var(--muted); text-align:center; font-size:12px; }
.translation-result { padding:18px; border:1px solid var(--border); border-radius:12px; background:var(--surface-soft); color:var(--text); font-family:Georgia,serif; font-size:16px; line-height:1.8; white-space:pre-wrap; overflow-wrap:anywhere; }
.translation-result p { margin:0 0 14px; }
.translation-result p:last-child { margin-bottom:0; }
.parallel-original { display:block; margin-top:5px; color:var(--muted); font-size:.84em; line-height:1.65; }
.word-hint { margin:12px 0 0; color:var(--muted); font-size:11px; text-align:center; }
.footer { display:flex; justify-content:space-between; gap:12px; padding:20px 5px 4px; color:var(--muted); font-size:11px; }
[hidden] { display:none !important; }
@media (max-width:620px) {
  .topbar { height:60px; padding:0 16px; }
  .app-shell { width:calc(100% - 22px); margin-top:15px; }
  .welcome-panel { min-height:0; padding:25px 21px; grid-template-columns:1fr; gap:20px; }
  .upload-button { justify-content:center; width:100%; }
  .file-name { margin-top:-10px; }
  .reader-panel,.translation-panel { padding:20px 16px; border-radius:16px; }
  .reader-toolbar { align-items:stretch; flex-direction:column; }
  .chapter-control { width:100%; }
  .reader-nav { display:grid; grid-template-columns:1fr 1fr; }
  .reader-nav button,.reader-bottom-nav button { padding:11px 7px; }
  .book-text { padding:23px 3px; font-size:16px; line-height:1.85; }
  .language-selectors { grid-template-columns:minmax(0,1fr) 34px minmax(0,1fr); gap:6px; }
  .language-field select { padding:11px 4px; font-size:12px; }
  .swap-button { width:34px; }
}
