:root {
  --bg: #faf9f6;
  --card: #ffffff;
  --soft: #f2efe9;
  --text: #1f1d1a;
  --muted: #6f6a62;
  --line: #e6e2da;
  --accent: #d9480f;
  --link: #b33b0c;
  --mark: #ffe066;
  --size: 19px;
  --font: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f4ecd8; --card: #f8f1df; --soft: #ebe1c8; --text: #4a3b28; --muted: #7d6a50; --line: #ddd0b2;
  --accent: #b5520f; --link: #8f3f0a; --mark: #f2cd5c;
}
:root[data-theme="dark"] {
  --bg: #171615; --card: #1f1e1c; --soft: #2a2826; --text: #e4dfd6; --muted: #9b958b; --line: #34322e;
  --accent: #ff7a3d; --link: #ff9a68; --mark: #6b5a12; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #171615; --card: #1f1e1c; --soft: #2a2826; --text: #e4dfd6; --muted: #9b958b; --line: #34322e;
    --accent: #ff7a3d; --link: #ff9a68; --mark: #6b5a12; color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.primary { border: 0; border-radius: 10px; padding: 11px 18px; background: var(--accent); color: #fff; font-weight: 600; }
.primary:disabled { opacity: .6; }
.error { color: #c92a2a; min-height: 1.4em; }

/* Giriş */
.login { display: grid; justify-items: center; text-align: center; padding: 15vh 24px 24px; gap: 4px; }
.login img { border-radius: 16px; }
.login h1 { margin: 8px 0 0; }
.login p { color: var(--muted); max-width: 340px; }
.login form { display: grid; gap: 10px; width: min(340px, 100%); margin-top: 8px; }
.code-input { text-align: center; font: 700 28px/1 ui-monospace, Menlo, Consolas, monospace !important; letter-spacing: .2em; }
.alt-login { margin-top: 18px; width: min(340px, 100%); color: var(--muted); font-size: 14px; }
.alt-login summary { cursor: pointer; }
.alt-login button { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px; }
.login input, dialog input, #search {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}

/* Üst çubuk */
.appbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 14px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand img { border-radius: 6px; }
.actions { display: flex; align-items: center; gap: 2px; }
.icon {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px;
  border: 0; background: none; border-radius: 10px; font-size: 19px; color: var(--text); text-decoration: none;
}
.icon:active { background: var(--soft); }
.icon.on { color: var(--accent); }
.icon.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-line { font-size: 12px; color: var(--muted); padding: 4px 14px 0; min-height: 18px; }
.sync-line.err { color: #c92a2a; }

.toolbar { padding: 8px 14px 0; }
.tabs { display: flex; gap: 4px; margin-top: 10px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 10px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.tabs span { font-weight: 400; color: var(--muted); }

/* Liste */
.list { list-style: none; margin: 0; padding: 4px 0 calc(env(safe-area-inset-bottom) + 24px); }
.item { display: grid; grid-template-columns: 1fr 76px; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.item:active { background: var(--soft); }
.item .title { font-weight: 650; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.item .thumb { width: 76px; height: 76px; border-radius: 8px; object-fit: cover; background: var(--soft); }
.item .ph { display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 22px; }
.item .tag { display: inline-block; border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; font-size: 11px; margin: 4px 4px 0 0; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 48px 24px; }

/* Okuma */
.progress { position: sticky; top: calc(env(safe-area-inset-top) + 57px); height: 3px; width: 0; background: var(--accent); z-index: 9; }
.article { max-width: 680px; margin: 0 auto; padding: 20px 18px calc(env(safe-area-inset-bottom) + 80px); }
.kicker { color: var(--accent); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.article h1 { font: 700 calc(var(--size) * 1.45)/1.22 var(--font); margin: 0 0 10px; }
.byline { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.hero { width: 100%; border-radius: 8px; margin-bottom: 20px; }
.summary { background: var(--soft); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin-bottom: 20px; }
.summary h2 { font-size: 14px; color: var(--accent); margin: 0 0 6px; }
#r-summary-body { font: calc(var(--size) * .85)/1.55 var(--font); }
#r-summary-body p { margin: 0 0 .5em; }
#r-summary-body ul { margin: 0; padding-left: 1.2em; }
.notice { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 20px; }
.notice p { margin: 0 0 10px; }
.content { font: var(--size)/1.7 var(--font); overflow-wrap: break-word; }
.content p { margin: 0 0 1.05em; }
.content h2, .content h3, .content h4 { line-height: 1.3; margin: 1.5em 0 .5em; }
.content a { color: var(--link); }
.content img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 1em auto; }
.content figure { margin: 1.3em 0; }
.content figcaption { color: var(--muted); font: 13px/1.4 system-ui, sans-serif; text-align: center; }
.content blockquote { margin: 1.2em 0; padding-left: .9em; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.content pre { background: var(--soft); padding: 10px; border-radius: 6px; overflow-x: auto; font-size: .8em; }
.content table { display: block; overflow-x: auto; border-collapse: collapse; font-size: .85em; }
.content td, .content th { border: 1px solid var(--line); padding: 5px 7px; }
mark.hl { background: var(--mark); color: inherit; border-radius: 2px; }
.highlights { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.highlights h2 { font-size: 17px; margin: 0 0 10px; }
.highlights ol { padding-left: 1.2em; margin: 0; }
.highlights li { margin-bottom: 12px; font: calc(var(--size) * .85)/1.5 var(--font); }
.highlights .note { color: var(--muted); font: 13px system-ui, sans-serif; margin-top: 3px; }
.end { text-align: center; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.hl-fab {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  border: 0; border-radius: 22px; padding: 11px 22px; background: var(--text); color: var(--bg);
  font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 20;
}

/* Sesli okuma */
.tts-active { background: color-mix(in srgb, var(--accent) 15%, transparent); border-radius: 4px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent); }
.player {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex; align-items: center; gap: 4px; padding: 8px;
  background: var(--text); color: var(--bg); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); z-index: 30;
}
.player button { border: 0; background: none; color: inherit; font-size: 18px; min-width: 44px; height: 44px; border-radius: 10px; }
.player .play { background: var(--accent); color: #fff; }
#tts-rate { font-size: 14px; font-weight: 600; }
.tts-progress { flex: 1; height: 4px; background: rgba(255, 255, 255, .2); border-radius: 2px; overflow: hidden; }
#tts-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
body.listening .hl-fab { bottom: calc(env(safe-area-inset-bottom) + 84px); }
body.listening .article { padding-bottom: calc(env(safe-area-inset-bottom) + 150px); }

/* Diyaloglar */
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100% - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog form { display: grid; gap: 10px; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
dialog .col { display: grid; gap: 8px; }
dialog button:not(.primary) { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  max-width: calc(100% - 32px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50;
}
.toast.err { background: #c92a2a; color: #fff; }
