:root {
  --bg: #E9EDF3;
  --panel: #FFFFFF;
  --panel-2: #F4F6F9;
  --hover: #EEF1F6;
  --ink: #18202E;
  --ink-2: #5A6376;
  --ink-3: #8A92A3;
  --line: #DADFE7;
  --accent: #2448C9;
  --accent-ink: #FFFFFF;
  --accent-soft: #E2E8FB;
  --danger: #C3263C;
  --ok: #138A5E;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 28px rgba(20, 30, 50, .10);
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F131A; --panel: #161B24; --panel-2: #1B212C; --hover: #202734;
    --ink: #E7EAF0; --ink-2: #A0A8B9; --ink-3: #737C8E; --line: #2A3140;
    --accent: #7E9BFF; --accent-ink: #0F131A; --accent-soft: #212C4D;
    --danger: #FF6B7F; --ok: #4FD1A1;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F131A; --panel: #161B24; --panel-2: #1B212C; --hover: #202734;
  --ink: #E7EAF0; --ink-2: #A0A8B9; --ink-3: #737C8E; --line: #2A3140;
  --accent: #7E9BFF; --accent-ink: #0F131A; --accent-soft: #212C4D;
  --danger: #FF6B7F; --ok: #4FD1A1;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
svg { width: 18px; height: 18px; flex: none; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.wide { width: 100%; }
.danger-text { color: var(--danger) !important; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: #D9A100; }
.linkish { border: 0; background: none; padding: 0; color: var(--ink-2); font-size: 13px; }
.linkish:hover { color: var(--accent); text-decoration: underline; }
.chip { height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 12.5px; font-weight: 600; }
.chip:hover { background: var(--hover); }
.chip.danger { color: var(--danger); }
.chip.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.primary:hover { filter: brightness(1.08); }
.icon-btn.sm { width: 28px; height: 28px; }

/* ---------- notifications ---------- */
.notify-box { padding: 0 2px; }
.notify-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: left; }
.notify-btn:hover { background: var(--hover); color: var(--ink); }
.notify-btn.on { border-style: solid; color: var(--ok); }
.notify-btn:disabled { cursor: default; opacity: .7; }
.notify-hint { margin: 6px 4px 0; line-height: 1.4; }
.notify-banner { display: flex; align-items: center; gap: 8px; margin: 0 14px 8px; padding: 8px 8px 8px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
.notify-banner span { flex: 1; }

/* ---------- stamps: one colour per site ---------- */
.stamp { --s: 28px; position: relative; width: var(--s); height: var(--s); flex: none; display: grid; place-items: center; border-radius: 5px; background: var(--c); color: #fff; font: 700 12px/1 var(--font-display); letter-spacing: -.02em; outline: 1.5px dashed var(--c); outline-offset: 2px; }
.stamp.all { background: var(--ink); outline-color: var(--ink); }
.stamp.sm { --s: 18px; font-size: 9.5px; border-radius: 3px; outline-width: 1px; outline-offset: 1.5px; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 18px 0 4px; font: 650 24px/1.2 var(--font-display); letter-spacing: -.01em; }
.login-card p { margin: 0 0 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 14px; }
.login-card input { display: block; width: 100%; margin-top: 6px; height: 42px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.login-mark, .stamp-stack { display: flex; gap: 10px; }
.login-mark span, .stamp-stack span { width: 22px; height: 22px; border-radius: 4px; background: var(--c); outline: 1.5px dashed var(--c); outline-offset: 2px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 0 0 12px !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px minmax(320px, 400px) 1fr; height: 100dvh; }
.rail { background: var(--bg); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.list-pane { background: var(--panel); border-left: 1px solid var(--line); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.reader { background: var(--panel-2); min-width: 0; display: flex; flex-direction: column; min-height: 0; }

/* rail */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 2px; font: 650 17px/1 var(--font-display); letter-spacing: -.01em; }
.brand svg { width: 24px; height: 24px; color: var(--accent); }
.compose-btn { justify-content: flex-start; height: 42px; margin: 4px 0 2px; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent); }
.rail-h { margin: 6px 10px 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.boxes, .folders { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.boxes button, .folders button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.boxes button { padding: 9px 10px 9px 12px; }
.boxes button:hover, .folders button:hover { background: var(--hover); }
.boxes button[aria-current="true"], .folders button[aria-current="true"] { background: var(--panel); box-shadow: 0 1px 2px rgba(20,30,50,.08); }
.box-text { flex: 1; min-width: 0; display: grid; }
.box-text b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-text span { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.count.quiet { background: transparent; color: var(--ink-3); }
.box-err { color: var(--danger); font-size: 12px; }
.folders svg { color: var(--ink-3); }
.folders button[aria-current="true"] svg { color: var(--accent); }
.folders .lbl { flex: 1; }
.rail-foot { margin-top: auto; display: flex; justify-content: space-between; padding: 8px 10px 0; border-top: 1px solid var(--line); }

/* list */
.list-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 8px 18px; }
.list-title { flex: 1; min-width: 0; }
.list-title h1 { margin: 0; font: 650 20px/1.2 var(--font-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-title span { font-size: 12.5px; }
.search { margin: 0 14px 8px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-3); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; border: 0; background: transparent; outline: none; color: var(--ink); min-width: 0; }
.bulkbar, .folder-tools { display: flex; align-items: center; gap: 10px; padding: 6px 14px 8px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.bulk-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; border-top: 1px solid var(--line); }
.msg { position: relative; display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 11px 14px 12px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); opacity: .9; }
.msg:hover { background: var(--hover); }
.msg[aria-selected="true"] { background: var(--accent-soft); }
.msg.unread .m-from, .msg.unread .m-subj { font-weight: 700; color: var(--ink); }
.msg.unread .m-dot { visibility: visible; }
.m-side { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 2px; }
.m-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); visibility: hidden; }
.m-main { min-width: 0; }
.m-top { display: flex; align-items: baseline; gap: 8px; }
.m-from { flex: 1; min-width: 0; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-date { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.m-subj { margin-top: 1px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-prev { margin-top: 2px; font-size: 13px; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.m-site { color: var(--c); font-weight: 600; filter: saturate(.9); }
.m-meta svg { width: 14px; height: 14px; }
.m-meta .star { color: #D9A100; }
.check { position: relative; width: 18px; height: 18px; display: inline-block; }
.check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.check span { position: absolute; inset: 0; border: 1.5px solid var(--ink-3); border-radius: 4px; background: var(--panel); }
.check input:checked + span { background: var(--accent); border-color: var(--accent); }
.check input:checked + span::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg .check { opacity: 0; }
.msg:hover .check, .msg .check:focus-within, .msg.picked .check, .selecting .msg .check { opacity: 1; }
.msg.picked .m-dot, .selecting .msg .m-dot { display: none; }
.list-empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.list-empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.more-btn { margin: 10px auto 14px; }
.skeleton { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.skeleton i { display: block; height: 10px; margin: 6px 0; border-radius: 4px; background: var(--hover); }

/* reader */
.reader-empty { margin: auto; text-align: center; color: var(--ink-2); display: grid; justify-items: center; gap: 4px; padding: 24px; }
.reader-empty .stamp-stack { margin-bottom: 14px; }
.reader-body { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.r-actions { display: flex; align-items: center; gap: 2px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.r-actions .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.r-actions .spacer { flex: 1; }
.r-actions .btn { height: 34px; padding: 0 12px; font-weight: 600; }
.r-head { padding: 22px 28px 14px; background: var(--panel); }
.r-subject { margin: 0 0 16px; font: 650 22px/1.3 var(--font-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
.r-from { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.r-who { flex: 1; min-width: 0; }
.r-who b { font-weight: 650; }
.r-who .addr { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.r-to { color: var(--ink-2); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.r-date { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.r-via { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.r-notice { margin: 0 28px 10px; padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.r-notice .linkish { color: var(--accent); font-weight: 600; }
.r-content { flex: 1; min-height: 240px; padding: 0 28px 20px; background: var(--panel); display: flex; flex-direction: column; }
.r-content iframe { flex: 1; width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.r-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.6; max-width: 76ch; }
.r-text a { color: var(--accent); }
.r-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 28px 20px; background: var(--panel); }
.att { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; background: var(--panel-2); max-width: 280px; }
.att:hover { border-color: var(--accent); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att small { color: var(--ink-3); white-space: nowrap; }
.r-scroll { overflow-y: auto; flex: 1; display: flex; flex-direction: column; background: var(--panel); }

/* compose */
.compose-wrap { position: fixed; inset: 0; background: rgba(15, 19, 26, .35); display: flex; align-items: flex-end; justify-content: flex-end; padding: 20px; z-index: 20; }
.compose { width: min(680px, 100%); height: min(720px, calc(100dvh - 40px)); background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.compose-head { display: flex; align-items: center; padding: 12px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.compose-head h2 { flex: 1; margin: 0; font: 650 16px/1.2 var(--font-display); }
.cfield { display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--line); min-height: 44px; }
.cfield label { width: 56px; font-size: 13px; color: var(--ink-3); flex: none; }
.cfield input, .cfield select { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; outline: none; }
.cfield select { cursor: pointer; }
.toolbar { display: flex; gap: 2px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.toolbar button { width: 32px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); }
.toolbar button:hover { background: var(--hover); color: var(--ink); }
.editor { flex: 1; overflow-y: auto; padding: 16px 20px; outline: none; font-size: 15px; line-height: 1.6; }
.editor:empty::before { content: "İletinizi yazın…"; color: var(--ink-3); }
.editor blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-2); white-space: pre-wrap; }
.editor a { color: var(--accent); }
.att-list { list-style: none; margin: 0; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 6px; }
.att-list li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; }
.att-list button { border: 0; background: none; color: var(--ink-3); width: 20px; height: 20px; border-radius: 4px; }
.att-list button:hover { color: var(--danger); }
#composeError { padding: 0 20px; margin: 6px 0 0 !important; }
.compose-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.compose-foot #discardBtn { margin-left: auto; }
.file-btn { cursor: pointer; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow); z-index: 30; max-width: calc(100% - 32px); }
.toast.err { background: var(--danger); color: #fff; }

.only-mobile { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 220px minmax(300px, 360px) 1fr; }
  .r-head, .r-content, .r-atts { padding-left: 20px; padding-right: 20px; }
  .r-notice { margin-left: 20px; margin-right: 20px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .r-from { flex-wrap: wrap; }
  .r-who { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .r-who .addr { display: block; overflow-wrap: anywhere; }
  .r-date { order: 3; flex-basis: 100%; padding-left: 52px; }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 15; box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .2s ease; }
  .app.menu-open .rail { transform: none; }
  .app.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,19,26,.35); z-index: 14; }
  .list-pane { border: 0; height: 100dvh; }
  .reader { position: fixed; inset: 0; z-index: 10; transform: translateX(100%); transition: transform .2s ease; }
  .app.reading .reader { transform: none; }
  .list-head { padding-left: 8px; }
  .compose-wrap { padding: 0; }
  .compose { height: 100dvh; width: 100%; border-radius: 0; border: 0; }
  .r-head { padding-top: 16px; }
  .r-subject { font-size: 19px; }
  /* installed app on phones: keep clear of the notch and home indicator */
  .rail { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .list-pane, .reader, .compose { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
