/* xhane — one shell, hairline dividers, cream + terracotta. */

:root {
  --paper: #faf9f5;
  --paper-2: #f2efe7;
  --surface: #ffffff;
  --ink: #262624;
  --ink-soft: #4a4742;
  --muted: #6f6a61;
  --line: #e5e0d5;
  --line-strong: #d6cfc1;
  --brand: #c96442;
  --accent: #b4522f;
  --accent-hover: #a24628;
  --accent-soft: #f7e8e1;
  --accent-ink: #ffffff;
  --ok: #2f7a5b;
  --ok-soft: #e4f1ea;
  --warn: #a2621c;
  --warn-soft: #f8eddb;
  --err: #b3382f;
  --err-soft: #fbe7e4;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(38, 38, 36, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --brand: #e08a63;
  --paper: #141312;
  --paper-2: #1c1b19;
  --surface: #1a1918;
  --ink: #ece8e0;
  --ink-soft: #cbc5bb;
  --muted: #948d82;
  --line: #2b2925;
  --line-strong: #3a3731;
  --accent: #e08a63;
  --accent-hover: #eaa07c;
  --accent-soft: #2a1f1a;
  --accent-ink: #1a110d;
  --ok: #6fbf94;
  --ok-soft: #1c2a23;
  --warn: #d9a05b;
  --warn-soft: #2b2419;
  --err: #e58079;
  --err-soft: #2c1d1c;
  --shadow: none;
}

* { box-sizing: border-box; }

/* Must win over the layout classes below: .login/.app/.view all set display,
   which would otherwise override the UA [hidden] rule and leave screens
   stacked on top of each other. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: inherit; text-decoration: none; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.i { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }

/* ---------------- brand ---------------- */
.brand { display: flex; align-items: center; gap: 9px; }
.mark {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--brand);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.mark svg { width: 14px; height: 14px; stroke: var(--accent-ink); stroke-width: 2.4; fill: none; stroke-linecap: round; }
.brand-name { font-size: 18px; font-weight: 620; letter-spacing: -0.02em; }
.brand-lg .mark { width: 30px; height: 30px; border-radius: 9px; }
.brand-lg .brand-name { font-size: 22px; }

/* ---------------- login ---------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--paper-2), transparent 70%),
    var(--paper);
}
.login-card { width: min(400px, 100%); }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 14px 0 22px; max-width: 34ch; }
.login-foot { color: var(--muted); font-size: 11.5px; margin-top: 22px; line-height: 1.6; }
#login-form { display: grid; gap: 14px; }

/* ---------------- shell ---------------- */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  border-right: 1px solid var(--line);
}
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 11px; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px; font-weight: 520;
  transition: background 120ms ease, color 120ms ease;
}
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item.is-active { background: var(--paper-2); border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.nav-item.is-active .i { color: var(--accent); }
.nav-count {
  margin-left: auto;
  min-width: 20px; height: 19px; padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.rail-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.conn { display: flex; align-items: center; gap: 7px; min-width: 0; margin-right: auto; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; }
.dot.is-ok { background: var(--ok); }
.dot.is-err { background: var(--err); }
.dot.is-warn { background: var(--warn); }
.conn-text { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); border-color: var(--line); }

.main { padding: 34px 44px 90px; min-width: 0; }
.view { max-width: 760px; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 7px;
}
h1 { font-size: 29px; font-weight: 680; letter-spacing: -0.025em; line-height: 1.15; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.head-meta { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: var(--surface);
}

/* ---------------- forms ---------------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 12px; font-weight: 620; color: var(--ink-soft); }
.field-hint { font-size: 11.5px; color: var(--muted); }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-inline { max-width: 340px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error {
  color: var(--err); font-size: 12.5px;
  background: var(--err-soft); border: 1px solid var(--err);
  border-radius: var(--radius-sm); padding: 8px 11px;
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent; color: var(--ink);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: var(--paper-2); color: var(--muted); border-color: var(--line); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); background: var(--paper-2); }
.btn-block { width: 100%; }
.btn.is-busy .i { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- segmented ---------------- */
.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.seg-wide { width: 100%; margin: 14px 0 16px; }
.seg-wide .seg-btn { flex: 1; }
.seg-btn {
  height: 28px; padding: 0 12px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 620; cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.notice {
  display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid var(--line);
  background: var(--warn-soft);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px; line-height: 1.5;
  margin-bottom: 12px;
}
.notice .i { color: var(--warn); width: 16px; height: 16px; margin-top: 1px; }
.notice a { color: var(--accent); font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- composer ---------------- */
.composer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 16px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.composer:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px var(--paper-2); }
.composer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.composer-hint { font-size: 11.5px; color: var(--muted); }
.tweets { display: grid; }
.tweet-row { display: grid; gap: 6px; padding: 4px 0 12px; }
.tweet-row + .tweet-row { border-top: 1px solid var(--line); padding-top: 14px; }
.tweet-row-head { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.tweet-index { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.tweet-del {
  margin-left: auto; width: 24px; height: 24px;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer;
}
.tweet-del:hover { background: var(--err-soft); color: var(--err); }
.tweet-input {
  border: 0 !important; padding: 2px 0 !important;
  background: transparent !important;
  font-size: 17px; line-height: 1.5; letter-spacing: -0.005em;
  resize: none; min-height: 56px; box-shadow: none !important;
}
.tweet-input::placeholder { color: var(--muted); opacity: 0.75; }
.add-tweet {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px; margin: 2px 0 10px;
  border: 1px dashed var(--line-strong); border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.add-tweet:hover { color: var(--accent); border-color: var(--accent); }

.composer-tools { display: flex; align-items: flex-start; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.schedule-field { display: grid; gap: 6px; }
.schedule-field .field-label { font-size: 11.5px; }
.schedule { display: flex; align-items: center; gap: 8px; color: var(--muted); flex-wrap: wrap; }
.schedule input[type="datetime-local"] {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  padding: 6px 9px; font-size: 12.5px; color: var(--ink);
}
.quick { display: flex; gap: 6px; }
.chip {
  height: 26px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); background: var(--paper-2); }

.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.composer-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.counter { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.counter .ring { width: 26px; height: 26px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 94.2; stroke-dashoffset: 94.2; transition: stroke-dashoffset 140ms ease, stroke 140ms ease; }
.counter.is-warn .ring-fg { stroke: var(--warn); }
.counter.is-over .ring-fg { stroke: var(--err); }
.counter.is-over { color: var(--err); font-weight: 600; }

/* ---------------- preview ---------------- */
.preview-wrap { margin-top: 26px; }
.tweet-card {
  margin-top: 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 16px;
}
.tweet-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  flex: 0 0 auto;
}
.tweet-ident { display: grid; line-height: 1.25; }
.tweet-name { font-weight: 650; font-size: 14px; }
.tweet-handle { color: var(--muted); font-size: 12.5px; }
.tweet-body { margin-top: 11px; font-size: 15.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------------- tabs + list ---------------- */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.tab {
  position: relative;
  height: 38px; padding: 0 1px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--ink); }
.tab.is-on::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.tab-count {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--paper-2); color: var(--muted);
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

.list { display: grid; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 15px 2px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.row-main { min-width: 0; display: grid; gap: 6px; }
.row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-text { font-size: 14px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.row-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.row-btn:hover { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
.row-btn.is-danger:hover { background: var(--err-soft); color: var(--err); border-color: var(--err); }
.row-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.01em;
}
.status-scheduled { background: var(--paper-2); color: var(--ink-soft); }
.status-draft { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.status-sent { background: var(--ok-soft); color: var(--ok); }
.status-failed { background: var(--err-soft); color: var(--err); }
.status-sending { background: var(--warn-soft); color: var(--warn); }

.empty {
  padding: 40px 4px;
  color: var(--muted);
  display: grid; gap: 6px; justify-items: start;
}
.empty strong { color: var(--ink); font-weight: 620; font-size: 14px; }
.empty p { font-size: 13px; max-width: 46ch; }

.thread-flag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}

/* ---------------- panels (settings) ---------------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.panel-note { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; max-width: 64ch; line-height: 1.6; }
.auth-block { display: grid; gap: 12px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.row-end { justify-content: flex-end; }
.conn-line { font-size: 12.5px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.conn-line.is-ok { color: var(--ok); }
.conn-line.is-err { color: var(--err); }

.facts { display: grid; gap: 10px; }
.facts > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------------- bottom nav ---------------- */
.bottom-nav { display: none; }

/* ---------------- toast ---------------- */
.toast-host {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 60; pointer-events: none;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 11px 13px;
  font-size: 13px; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: toast-in 160ms ease-out;
  overflow-wrap: anywhere;
}
.toast .i { width: 16px; height: 16px; margin-top: 1px; }
.toast.is-err { background: var(--err); color: #fff; }
.toast.is-ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .main { padding: 20px 16px 96px; }
  .view-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  h1 { font-size: 24px; }
  .composer { padding: 14px 13px 10px; }
  .composer-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .composer-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .composer-actions .btn-primary { grid-column: 1 / -1; }
  .counter { order: -1; justify-content: flex-end; }
  .grid-2 { grid-template-columns: 1fr; }
  .facts > div { grid-template-columns: 1fr; gap: 2px; }
  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .bn-item {
    flex: 1; height: 46px;
    display: grid; place-items: center; gap: 2px;
    border-radius: 10px;
    color: var(--muted); font-size: 10.5px; font-weight: 600;
  }
  .bn-item.is-active { color: var(--accent); background: var(--accent-soft); }
  .toast-host { bottom: 74px; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .row-actions { justify-content: flex-start; }
}

@media (max-width: 420px) {
  .quick { display: none; }
  .seg-wide .seg-btn { padding: 0 6px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
