:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --favorite: #ff9f0a;
  --danger: #ff3b30;
  --success: #34c759;
  --border: rgba(0, 0, 0, 0.06);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.05), 0 10px 28px rgba(0, 0, 0, 0.09);
  --nav-bg: rgba(255, 255, 255, 0.72);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --favorite: #ff9f0a;
    --danger: #ff453a;
    --success: #30d158;
    --border: rgba(255, 255, 255, 0.09);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.45);
    --nav-bg: rgba(28, 28, 30, 0.72);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Top nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.25rem;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  flex: none;
  white-space: nowrap;
}

.nav-row {
  display: flex;
  gap: 1.1rem;
  margin-top: 0.5rem;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.nav-row::-webkit-scrollbar { display: none; }
.nav-row a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: color 0.15s ease;
}
.nav-row a:hover { color: var(--text); }
.unread-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger, #ff3b30);
  color: white;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.4;
  vertical-align: middle;
}

.search-form { display: flex; flex: 1 1 auto; min-width: 0; margin: 0; }
.search-form input {
  width: 100%;
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 980px;
  background: var(--border);
  color: var(--text);
}
.search-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.account-menu { position: relative; flex: none; }
.username-btn {
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.35rem 0.7rem;
  border-radius: 980px;
  border: 1px solid var(--border);
}
.username-btn:hover { background: var(--border); color: var(--text); }
.username-btn:active { transform: none; }

.account-dropdown {
  display: none;
  flex-direction: column;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 160px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
  padding: 0.4rem;
  z-index: 20;
}
.account-dropdown.open { display: flex; }
.account-dropdown a, .account-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: none;
}
.account-dropdown a:hover, .account-dropdown button:hover { background: var(--border); }
.account-dropdown form { margin: 0; }

.content { max-width: 900px; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; }

@media (max-width: 600px) {
  .topbar { padding: 0.5rem 0.9rem; }
  .content { padding: 1rem 0.9rem 3rem; }
  .search-form input { min-width: 0; font-size: 0.85rem; }
  .nav-row { gap: 0.85rem; }
}

h1 { margin-top: 0; font-weight: 650; letter-spacing: -0.02em; }

.view-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  float: right;
  margin-top: 0.1rem;
}
.view-selector-form { display: inline-flex; margin: 0; }
.view-selector-form select {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
}
.view-selector-input {
  padding: 0.4rem 0.6rem;
  border-radius: 8px 0 0 8px;
  border: 1px solid var(--border);
  border-right: none;
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  width: 9rem;
}
.view-selector-form:has(.view-selector-input) button { border-radius: 0 8px 8px 0; }
.view-as-tag { background: var(--accent); color: white; }
@media (max-width: 700px) {
  .view-selector { float: none; margin: 0.75rem 0; }
}

/* ---------- Buttons ---------- */

.btn, button, .cancel {
  display: inline-block;
  padding: 0.55rem 1.2rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 980px;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover, button:hover, .cancel:hover { background: var(--accent-hover); }
.btn:active, button:active { transform: scale(0.97); }

.cancel { background: var(--border); color: var(--text); margin-left: 0.6rem; }
.cancel:hover { background: var(--border); opacity: 0.8; }

.btn.secondary { background: var(--border); color: var(--text); }
.btn.secondary:hover { background: var(--border); opacity: 0.8; }

.genre-toolbar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }

.link-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  transition: opacity 0.15s ease;
}
.link-btn:hover { background: none; opacity: 0.7; }
.link-btn.accent { color: var(--accent); }
.link-btn:disabled { color: var(--border); cursor: default; opacity: 1; }

.reorder-btns { display: flex; flex-direction: column; gap: 0.1rem; }
.reorder-btns .link-btn { color: var(--muted); font-size: 0.7rem; line-height: 1; }
.reorder-btns .link-btn:disabled { color: var(--border); }

/* ---------- Browse (read-only, by genre) ---------- */

.browse-section { margin-bottom: 2rem; }

.browse-parent-title {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 0.9rem;
}
.browse-parent-title:hover { color: var(--accent); }

.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.browse-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.browse-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.browse-card-thumb { width: 100%; aspect-ratio: 16 / 9; background: var(--bg); }
.browse-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.browse-card-body { padding: 0.9rem 1rem; }
.browse-card-title { font-weight: 600; font-size: 0.98rem; margin-bottom: 0.3rem; }
.browse-card-meta { color: var(--muted); font-size: 0.8rem; }

/* ---------- Spending dashboard ---------- */

.spending-controls { margin-bottom: 1rem; }

.spending-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.spending-tabs .tag { text-decoration: none; padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.spending-tabs .tag.active { background: var(--accent); color: white; }

.spending-summary {
  display: flex;
  gap: 2rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.spending-summary-figure { display: flex; flex-direction: column; gap: 0.3rem; }
.spending-summary-label { color: var(--muted); font-size: 0.8rem; }
.spending-summary-value { font-size: 1.3rem; font-weight: 650; }

.spending-chart-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem 1.5rem 1rem;
  margin-bottom: 1.5rem;
}
.spending-chart {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: min-content;
}
.spending-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 36px;
  cursor: default;
}
.spending-bar-value {
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1;
  margin-bottom: 0.3rem;
  writing-mode: vertical-rl;
  text-orientation: sideways;
  transform: rotate(180deg);
  max-height: 3.2rem;
}
/* Fixed-height track, independent of the label below — this is what keeps
   every bar's bottom edge aligned regardless of how tall each label renders. */
.spending-bar-track {
  height: 140px;
  width: 100%;
  display: flex;
  align-items: flex-end;
}
.spending-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: opacity 0.15s ease;
}
.spending-bar-col:hover .spending-bar { opacity: 0.7; }
/* Stacked bar: segments are flex children along the column axis, each sized
   by flex-basis (% of this bar's own height) so they stay proportional
   regardless of the bar's total height. */
.spending-bar-stack {
  width: 100%;
  min-height: 2px;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  transition: opacity 0.15s ease;
}
.spending-bar-col:hover .spending-bar-stack { opacity: 0.7; }
.spending-bar-segment { width: 100%; }
/* Fully vertical (reads bottom-to-top, like a -90° rotated axis label).
   writing-mode does the layout — the browser reserves exactly the height the
   text needs, so every bar can carry a label without them colliding. */
.spending-bar-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.4rem;
  white-space: nowrap;
  writing-mode: vertical-rl;
  text-orientation: sideways;
  transform: rotate(180deg);
  max-height: 4.6rem;
}
/* Per-user chart has few bars and text labels (usernames) — keep those
   upright and readable instead of rotating like the time-axis labels. */
.spending-bar-label.horizontal,
.spending-bar-value.horizontal {
  writing-mode: horizontal-tb;
  transform: none;
  max-height: none;
}
.per-user-chart .spending-bar-col { width: auto; min-width: 70px; padding: 0 0.5rem; }
/* Subtle separator where the label repeats the date — helps the eye chunk
   a long run of bars (e.g. 48 hourly bars) into days without extra labels. */
.spending-bar-col.boundary { border-left: 1px dashed var(--border); padding-left: 4px; margin-left: 3px; }

.kind-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  margin-bottom: 1.5rem;
}
.kind-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.kind-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  flex: none;
}
.kind-legend-label { color: var(--muted); }
.kind-legend-value { font-weight: 600; }
.kind-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 0.9rem;
}

/* ---------- Genre tree ---------- */

.genre-tree, .genre-children { list-style: none; padding-left: 0; margin-top: 1.25rem; }
.genre-children { padding-left: 1.5rem; margin-top: 0.6rem; }

.genre-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.6rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.genre-row:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.genre-row.disabled {
  border: 1px solid var(--border);
  box-shadow: none;
  opacity: 0.7;
}
.genre-row.disabled:hover { box-shadow: none; transform: none; }

.genre-row a:first-child { font-weight: 600; color: var(--text); text-decoration: none; }
.genre-row .tags { display: flex; gap: 0.4rem; }
.tag {
  background: var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.2rem 0.65rem;
  border-radius: 980px;
  text-decoration: none;
  font-weight: 500;
}
.genre-row .actions { margin-left: auto; display: flex; gap: 0.9rem; align-items: center; font-size: 0.85rem; }

/* ---------- Forms ---------- */

.card-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  max-width: 480px;
}
.card-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.88rem; color: var(--muted); }
.card-form input, .card-form select, .card-form textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
}
.card-form input:focus, .card-form select:focus, .card-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.collect-form { margin-bottom: 1.25rem; }

.hint { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); }
.success { color: var(--success); }
.empty { color: var(--muted); }

/* ---------- Article list ---------- */

.article-list { list-style: none; padding: 0; }
.article-card {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  cursor: pointer;
}
.article-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

.article-thumb {
  flex: none;
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
}
.article-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.article-title {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.article-title:hover { color: var(--accent); }
.article-summary { color: var(--muted); margin: 0.4rem 0; font-size: 0.92rem; }
.article-meta { display: flex; gap: 0.5rem; align-items: center; }
.article-meta .date { color: var(--muted); font-size: 0.78rem; margin-left: auto; }

.source-link-small {
  display: inline-block;
  margin-top: 0.5rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
}
.source-link-small:hover { color: var(--accent-hover); }

.fav-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  transition: transform 0.15s ease, color 0.15s ease;
}
.fav-btn:hover { background: none; transform: scale(1.15); }
.fav-btn.active { color: var(--favorite); }
.fav-btn-readonly { font-size: 1.5rem; color: var(--muted); line-height: 1; opacity: 0.6; }

/* ---------- Article detail ---------- */

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}
.back-link:hover { color: var(--accent-hover); }

.detail-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.detail-thumb {
  width: 100%;
  max-height: 360px;
  overflow: hidden;
  border-radius: 14px;
  margin-bottom: 1.5rem;
  background: var(--bg);
}
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-meta { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.detail-meta .date { color: var(--muted); font-size: 0.8rem; margin-left: auto; }

.detail-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}

.detail-body {
  white-space: pre-line;
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text);
}

.detail-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.source-links { display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-end; }

.source-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
}
.source-link:hover { color: var(--accent-hover); }

/* ---------- Users table ---------- */

.user-table { width: 100%; border-collapse: collapse; margin-bottom: 2rem; }
.user-table th, .user-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.user-table th { color: var(--muted); font-weight: 500; font-size: 0.82rem; }
.inline-form { display: flex; gap: 0.4rem; align-items: center; }
.inline-form label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.inline-form input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.user-list { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 2rem; }
.user-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.user-card.disabled { opacity: 0.6; }
.user-card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.user-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.user-card-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; padding-top: 0.6rem; border-top: 1px solid var(--border); }

/* ---------- Usage log (cards) ---------- */

.usage-list { display: flex; flex-direction: column; gap: 0.75rem; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.pager a { color: var(--accent); text-decoration: none; }
.pager a:hover { text-decoration: underline; }

.usage-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.usage-card.has-error { border: 1px solid var(--danger); }

.usage-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.usage-date { color: var(--muted); font-size: 0.82rem; }
.usage-cost { margin-left: auto; font-weight: 600; font-size: 0.9rem; }

.usage-card-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.usage-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.query-tag { max-width: 100%; overflow-wrap: break-word; }

.usage-error {
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.85rem;
  overflow-wrap: break-word;
}

/* ---------- Chat ---------- */

.chat-layout { display: flex; gap: 1.5rem; align-items: flex-start; }

.chat-sidebar {
  flex: none;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 5rem;
}
.chat-new-btn { text-align: center; }

.chat-thread-list { display: flex; flex-direction: column; gap: 0.35rem; max-height: 70vh; overflow-y: auto; }

.chat-thread-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s ease;
}
.chat-thread-item:hover { background: var(--border); }
.chat-thread-item.active { background: var(--card); box-shadow: var(--shadow); }

.chat-thread-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-meta { display: flex; align-items: center; gap: 0.35rem; }
.chat-thread-meta .date { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

.chat-main { flex: 1; min-width: 0; }

@media (max-width: 700px) {
  .chat-layout { flex-direction: column; }
  .chat-sidebar { width: 100%; position: static; }
  .chat-thread-list { flex-direction: row; overflow-x: auto; overflow-y: visible; max-height: none; padding-bottom: 0.3rem; }
  .chat-thread-item { flex: none; width: 160px; }
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  align-self: flex-start;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}
.chat-bubble-text { white-space: pre-line; line-height: 1.6; }

.chat-bubble.chat-error-bubble { color: var(--danger); }

.typing-dots { display: inline-flex; gap: 0.25rem; align-items: center; padding: 0.2rem 0; }
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-tool-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.chat-proposal {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-proposal-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.chat-proposal-text {
  font-size: 0.88rem;
  white-space: pre-line;
  background: var(--bg);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.chat-input-form {
  display: flex;
  gap: 0.6rem;
  position: sticky;
  bottom: 1rem;
}
.chat-input-form input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 980px;
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
}
.chat-input-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  margin: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Yu Gothic", sans-serif;
}
.login-card {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-hover);
  padding: 2.5rem;
  width: 320px;
}
.login-card h1 { text-align: center; letter-spacing: -0.02em; }
.login-card label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.88rem; color: var(--muted); }
.login-card input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
