/* Dark, list-first layout modeled on the iOS grouped-list idiom. */
:root {
  color-scheme: dark;
  --bg: #000;
  --cell: #1c1c1e;
  --cell-pressed: #2c2c2e;
  --separator: #38383a;
  --text: #fff;
  --text-2: #8e8e93;
  --text-3: #636366;
  --blue: #0a84ff;
  --red: #ff453a;
  --bar: rgba(18, 18, 20, 0.82);
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC",
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.3 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.icon { width: 24px; height: 24px; flex: none; }

.screen {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* Navigation bar */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 44px;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
  display: flex;
  align-items: center;
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
/* The root screen has no back button, so it skips the bar and keeps its height. */
.screen.root { padding-top: calc(44px + env(safe-area-inset-top)); }
.back { display: flex; align-items: center; gap: 2px; color: var(--blue); min-height: 44px; padding-right: 8px; }
.back .icon { width: 26px; height: 26px; stroke-width: 2.2; }

.large-title {
  margin: 4px var(--gutter) 4px;
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.subtitle { margin: 0 var(--gutter) 10px; color: var(--text-2); font-size: 15px; }
.section-title {
  margin: 18px calc(var(--gutter) + 16px) 8px;
  font-size: 20px;
  font-weight: 700;
}
.placeholder { margin: 48px var(--gutter); text-align: center; color: var(--text-2); }
.creator { margin: -6px var(--gutter) 10px; color: var(--text-2); font-size: 13px; }
/* The @user name shown after an alias. */
.handle { margin-left: 6px; color: var(--text-2); font-weight: 400; }
.account-section { margin: 20px var(--gutter); padding: 16px; background: var(--cell); border-radius: 10px; }
.account-section h2 { margin-top: 0; font-size: 20px; }
.account-section p { line-height: 1.45; }
.account-section label { display: block; margin-top: 12px; }
.account-section .field { background: var(--cell-pressed); border-radius: 6px; margin-top: 6px; }
.account-section .save-button { margin-left: 0; margin-right: 0; width: 100%; }
.account-section .text-button { display: block; margin-top: 8px; }
.account-links, .account-notice { margin: 16px var(--gutter); }
.account-notice { white-space: pre-wrap; overflow-wrap: anywhere; }
.signer { border-top: 1px solid var(--separator); margin-top: 16px; padding-top: 10px; }
.fingerprint { font-family: monospace; overflow-wrap: anywhere; user-select: all; }
.turnstile-frame { width: 100%; height: 120px; border: 0; }
.page-controls { margin: 12px var(--gutter); display: flex; flex-wrap: wrap; gap: 20px; }

/* Settings */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 16px; }
.setting-value { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footnote { margin: 8px calc(var(--gutter) + 16px) 0; color: var(--text-2); font-size: 13px; }
.footnote.saved { color: var(--text); }
.save-button {
  display: block;
  margin: 20px var(--gutter) 0;
  width: calc(100% - 2 * var(--gutter));
  min-height: 44px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.save-button:disabled { background: var(--cell-pressed); color: var(--text-3); }

/* Grouped inset list (board list) */
.group {
  list-style: none;
  margin: 0 var(--gutter);
  padding: 0;
  background: var(--cell);
  border-radius: 10px;
  overflow: hidden;
}
.board-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 14px 0 16px;
  position: relative;
}
.group li + li .board-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 54px;
  border-top: 0.5px solid var(--separator);
}
.board-row:active, .thread-row:active { background: var(--cell-pressed); }
.row-icon { color: var(--blue); width: 26px; height: 26px; stroke-width: 1.5; }
.row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--text-2); }
.chevron { color: var(--text-3); width: 18px; height: 18px; stroke-width: 2.4; }
.chevron.small { width: 14px; height: 14px; }

/* Search field */
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 var(--gutter) 10px;
  padding: 0 8px;
  height: 36px;
  border-radius: 10px;
  background: var(--cell);
  color: var(--text-2);
}
.search .icon { width: 18px; height: 18px; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
}
.search input::placeholder { color: var(--text-2); }

/* Plain list (thread list) */
.plain-list { list-style: none; margin: 0; padding: 0; }
.thread-row {
  display: flex;
  gap: 6px;
  padding: 10px var(--gutter) 10px 6px;
  position: relative;
}
.plain-list li + li .thread-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 26px;
  border-top: 0.5px solid var(--separator);
}
.dot { flex: none; width: 10px; height: 10px; margin: 6px 2px 0 2px; border-radius: 50%; }
.thread-row.unread .dot { background: var(--blue); }
.thread-main { flex: 1; min-width: 0; }
.thread-top { display: flex; align-items: center; gap: 6px; }
.author { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { color: var(--text-2); font-size: 15px; white-space: nowrap; }
.subject { font-size: 15px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excerpt {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.inline { width: 15px; height: 15px; margin-right: 4px; vertical-align: -2px; color: var(--text-2); }

/* Thread */
.thread-title { margin: 8px var(--gutter) 12px; font-size: 24px; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.thread-title .inline { width: 20px; height: 20px; }
.posts { border-top: 0.5px solid var(--separator); }
.post { padding: 14px var(--gutter); border-bottom: 0.5px solid var(--separator); }
.post-head { display: flex; align-items: center; gap: 10px; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(#6e6e73, #48484a);
  font-weight: 600;
  font-size: 15px;
}
.body { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.body.hidden { color: var(--text-2); font-style: italic; }

/* Bottom toolbar */
.toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  height: calc(49px + env(safe-area-inset-bottom));
  padding: 0 var(--gutter) env(safe-area-inset-bottom);
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--separator);
}
.toolbar-spacer { flex: 1; display: flex; justify-content: flex-end; }
.toolbar-status { font-size: 12px; color: var(--text); white-space: nowrap; }
.tool-button { color: var(--blue); display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; }
.tool-button:disabled { color: var(--text-3); }
.tool-button .icon { width: 26px; height: 26px; }

/* Compose sheet */
/* Wraps a screen behind the sheet so it can go inert without changing layout. */
.screen-content { display: contents; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.55); animation: fade 0.2s ease-out; }
.sheet {
  position: fixed;
  z-index: 11;
  left: 0;
  right: 0;
  bottom: 0;
  top: max(44px, env(safe-area-inset-top));
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--cell);
  border-radius: 12px 12px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--gutter);
  border-bottom: 0.5px solid var(--separator);
}
.sheet-title { font-weight: 600; }
.text-button { color: var(--blue); min-height: 44px; }
.send-button { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; }
.send-button:disabled { background: var(--cell-pressed); color: var(--text-3); }
.send-button .icon { width: 20px; height: 20px; stroke-width: 2.4; }
.field {
  width: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: inherit;
  padding: 12px var(--gutter);
}
.field::placeholder { color: var(--text-3); }
.subject-field { border-bottom: 0.5px solid var(--separator); font-weight: 600; }
.body-field { flex: 1; resize: none; line-height: 1.45; }
.error { margin: 0; padding: 10px var(--gutter); color: var(--red); font-size: 15px; }

@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { animation: none; }
}
