/* OGS — shared design tokens & components (Apple-style minimal). */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --sidebar: #f2f2f4;
  --fill: rgba(0, 0, 0, 0.045);
  --fill-2: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: #d2d2d7;
  --sep: rgba(0, 0, 0, 0.09);
  --accent: #0071e3;
  --accent-2: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --link: #0066cc;
  --danger: #e30000;
  --ok: #1f9d4a;
  --warn: #b25000;
  --focus: 0 0 0 4px rgba(0, 125, 250, 0.35);
  --shadow-window: 0 30px 80px rgba(0, 0, 0, 0.22), 0 0 0 0.5px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --bg-2: #161617; --surface: #1c1c1e; --surface-2: #2c2c2e; --sidebar: #232325;
    --fill: rgba(255, 255, 255, 0.07); --fill-2: rgba(255, 255, 255, 0.12);
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #86868b; --line: #424245; --sep: rgba(255, 255, 255, 0.1);
    --accent: #0a84ff; --accent-2: #409cff; --accent-soft: rgba(10, 132, 255, 0.18); --link: #2997ff;
    --danger: #ff453a; --ok: #30d158; --warn: #ff9f0a;
    --shadow-window: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --bg-2: #161617; --surface: #1c1c1e; --surface-2: #2c2c2e; --sidebar: #232325;
  --fill: rgba(255, 255, 255, 0.07); --fill-2: rgba(255, 255, 255, 0.12);
  --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #86868b; --line: #424245; --sep: rgba(255, 255, 255, 0.1);
  --accent: #0a84ff; --accent-2: #409cff; --accent-soft: rgba(10, 132, 255, 0.18); --link: #2997ff;
  --danger: #ff453a; --ok: #30d158; --warn: #ff9f0a;
  --shadow-window: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.14);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 17px/1.47 var(--font);
  letter-spacing: -0.022em; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button, a, [role="button"] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* iOS zooms the page when a focused input is < 16px — keep all inputs at 16px+ on touch devices. */
@media (pointer: coarse), (max-width: 699px) {
  input, textarea, select { font-size: 16px !important; }
}
/* Hover styles only where hover exists (avoids "sticky" hover after a tap). */
@media (hover: none) {
  .btn:hover { background: var(--accent); }
  .btn.secondary:hover { background: var(--fill); }
  .row.clickable:hover, .nav:hover, .acct:hover, .me:hover, .icon-btn:hover { background: inherit; }
  .row.clickable:active, .acct:active, .me:active, .nav:active { background: var(--fill-2); }
}
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

/* Smooth theme switch fallback (when View Transitions are unavailable). */
html.theming, html.theming * { transition: background-color .45s ease, color .45s ease, border-color .45s ease, fill .45s ease !important; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; animation-timing-function: ease; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 22px; border: 0; border-radius: 980px; cursor: pointer;
  font-size: 17px; font-weight: 400; background: var(--accent); color: #fff; white-space: nowrap;
  transition: background-color .2s, opacity .2s, transform .1s;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn[disabled] { opacity: .4; cursor: default; }
.btn.secondary { background: var(--fill); color: var(--text); }
.btn.secondary:hover { background: var(--fill-2); }
.btn.danger { background: transparent; color: var(--danger); padding: 0 6px; }
.btn.danger:hover { background: transparent; text-decoration: underline; }
.btn.small { min-height: 30px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.link { background: none; color: var(--link); padding: 0; min-height: 0; border-radius: 4px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn .spin { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; display: inline-grid; place-items: center;
  background: var(--fill); color: var(--text-2); cursor: pointer; transition: background .2s;
}
.icon-btn:hover { background: var(--fill-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Floating-label fields ---------- */
.field { position: relative; }
.field input, .field textarea {
  width: 100%; height: 56px; padding: 22px 16px 6px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); outline: none; font-size: 17px; transition: border-color .2s, box-shadow .2s;
}
.field textarea { height: auto; min-height: 96px; resize: vertical; padding-top: 26px; font-family: var(--mono); font-size: 14px; }
.field label {
  position: absolute; left: 17px; top: 17px; color: var(--text-3); pointer-events: none; font-size: 17px;
  transform-origin: left top; transition: transform .18s ease, color .18s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
.field input:focus + label, .field input:not(:placeholder-shown) + label,
.field textarea:focus + label, .field textarea:not(:placeholder-shown) + label { transform: translateY(-10px) scale(0.72); }
.field.invalid input { border-color: var(--danger); }
.field .suffix { position: absolute; right: 16px; top: 23px; color: var(--text-3); font-size: 15px; pointer-events: none; }
.field .trailing { position: absolute; right: 8px; top: 8px; }
.field.has-suffix input { padding-right: 150px; }
.field.has-trailing input { padding-right: 56px; }
.hint { font-size: 13px; color: var(--text-2); margin: 6px 4px 0; line-height: 1.4; letter-spacing: -0.01em; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--ok); }

.arrow-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--text-3); background: transparent;
  color: var(--text-2); display: grid; place-items: center; cursor: pointer; transition: all .2s;
}
.arrow-btn:hover:not([disabled]) { border-color: var(--text); color: var(--text); }
.arrow-btn[disabled] { opacity: .35; cursor: default; }
.arrow-btn svg { width: 16px; height: 16px; }

/* ---------- Grouped lists (Settings-style) ---------- */
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.group + .group, .group-title + .group { margin-top: 8px; }
.group-title { font-size: 13px; color: var(--text-2); margin: 22px 12px 6px; font-weight: 500; letter-spacing: -0.01em; }
.group-foot { font-size: 12px; color: var(--text-2); margin: 6px 12px 0; line-height: 1.45; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 14px; position: relative; font-size: 14px;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row .label { flex: 1; min-width: 0; }
.row .value { color: var(--text-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { display: block; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--fill); }
.row input.inline {
  border: 0; background: transparent; text-align: right; color: var(--text); outline: none; font-size: 14px; min-width: 0; flex: 1;
  padding: 4px 6px; border-radius: 6px;
}
.row input.inline:focus { background: var(--fill); text-align: left; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 980px; background: var(--fill-2); color: var(--text-2); font-weight: 500; letter-spacing: 0; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: rgba(255, 159, 10, .16); color: var(--warn); }

/* ---------- Toggle ---------- */
.toggle { position: relative; width: 44px; height: 26px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 26px; background: var(--fill-2); transition: background .25s; }
.toggle span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .25s cubic-bezier(.3,.7,.2,1);
}
.toggle input:checked + span { background: #34c759; }
.toggle input:checked + span::after { transform: translateX(18px); }
.toggle input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- Misc ---------- */
.spin { width: 20px; height: 20px; border: 2.5px solid var(--fill-2); border-top-color: var(--text-2); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar { border-radius: 50%; object-fit: cover; background: var(--fill); flex: none; display: block; }
.muted { color: var(--text-2); }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: 0; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 100;
  background: rgba(29, 29, 31, .92); color: #fff; padding: 10px 18px; border-radius: 980px; font-size: 14px;
  transition: opacity .25s, transform .3s cubic-bezier(.3,.7,.2,1); pointer-events: none; backdrop-filter: blur(20px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Theme switch (bottom corner on standalone pages) */
.theme-switch {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 2px; padding: 3px; border-radius: 980px;
  background: var(--fill); backdrop-filter: blur(20px);
}
.theme-switch button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.theme-switch button svg { width: 15px; height: 15px; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

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