:root {
  color-scheme: dark;
  --ink: #f6efd9;
  --muted: #b8ad91;
  --panel: #151712;
  --panel-2: #1d211a;
  --line: #383929;
  --gold: #d8a93a;
  --gold-light: #f3d57a;
  --green: #6eaa6f;
  --red: #d06b62;
  --shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: #0d0f0b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(216, 169, 58, .16), transparent 30%),
    radial-gradient(circle at 90% 80%, rgba(77, 112, 68, .15), transparent 32%),
    linear-gradient(135deg, #0b0e0a, #171a13);
}
.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 28px 28px;
}
.auth-card {
  width: min(100%, 440px);
  padding: 38px;
  text-align: center;
  border: 1px solid rgba(216, 169, 58, .28);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(31, 34, 27, .97), rgba(18, 20, 16, .98));
  box-shadow: var(--shadow);
  position: relative;
}
.coin-seal {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: -4px auto 20px;
  font-size: 38px;
  border: 1px solid rgba(243, 213, 122, .48);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(216, 169, 58, .22), rgba(90, 69, 20, .08));
  box-shadow: inset 0 0 0 7px rgba(216, 169, 58, .05), 0 10px 30px rgba(0,0,0,.28);
}
.eyebrow { color: var(--gold-light); text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 800; }
.auth-card h1 { margin: 8px 0 4px; font-family: Georgia, serif; font-size: 35px; }
.auth-copy { margin: 8px auto 26px; color: var(--muted); line-height: 1.55; max-width: 330px; }
.auth-form { display: grid; gap: 10px; text-align: left; }
.auth-form label { margin-top: 5px; font-weight: 700; font-size: 13px; }
.auth-form label span { float: right; color: var(--muted); font-size: 11px; font-weight: 500; }
.auth-form input {
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #0f110e;
}
.auth-form input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216,169,58,.12); }
.primary-button, .secondary-button {
  border: 0;
  border-radius: 12px;
  padding: 12px 17px;
  cursor: pointer;
  font-weight: 800;
}
.primary-button { color: #241b08; background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.primary-button:hover { filter: brightness(1.07); }
.auth-form .primary-button { margin-top: 12px; width: 100%; }
.secondary-button { border: 1px solid var(--line); background: var(--panel-2); }
button:disabled { opacity: .5; cursor: wait; }
.form-error { min-height: 18px; margin: 4px 0 0; color: #ef8f87; font-size: 13px; }
.local-oath { margin-top: 22px; padding: 11px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }

.app-page { overflow: hidden; }
.app-shell { height: 100vh; display: grid; grid-template-columns: 290px 1fr; }
.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #171a14, #10120e);
}
.brand-block { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-mark { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 50%; background: rgba(216,169,58,.12); border: 1px solid rgba(216,169,58,.35); font-size: 23px; }
.brand-block strong { display: block; font-family: Georgia, serif; font-size: 17px; }
.brand-block span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.new-thread-button {
  padding: 11px 14px;
  border: 1px solid rgba(216,169,58,.35);
  border-radius: 11px;
  cursor: pointer;
  background: rgba(216,169,58,.09);
  font-weight: 800;
  text-align: left;
}
.new-thread-button:hover { background: rgba(216,169,58,.16); }
.thread-list { flex: 1; overflow: auto; margin: 14px 0; display: flex; flex-direction: column; gap: 5px; }
.thread-button {
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-button:hover, .thread-button.active { color: var(--ink); background: rgba(255,255,255,.055); }
.thread-button.active { box-shadow: inset 3px 0 var(--gold); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; }
.ghost-button { width: 100%; padding: 9px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; color: var(--muted); }
.ghost-button:hover { background: rgba(255,255,255,.05); color: var(--ink); }
.ghost-button .alert-badge {
  float: right;
  min-width: 20px;
  padding: 2px 6px;
  color: #fff4e0;
  border: 1px solid rgba(230, 102, 81, .48);
  border-radius: 999px;
  background: #8f3028;
  text-align: center;
  font-size: 9px;
  font-weight: 900;
  box-shadow: 0 0 14px rgba(208, 72, 56, .28);
}
.sidebar-foot p { margin: 8px 9px 0; color: #706b59; font-size: 11px; }

.chat-panel { min-width: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: radial-gradient(circle at 85% 0, rgba(216,169,58,.055), transparent 30%), #11130f; }
.chat-header { min-height: 74px; display: flex; align-items: center; gap: 13px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: rgba(17,19,15,.92); }
.chat-header h1 { margin: 0; max-width: 650px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: Georgia, serif; font-size: 20px; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.icon-button { display: none; border: 0; background: transparent; cursor: pointer; font-size: 21px; }
.provider-badge { margin-left: auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.025); font-size: 11px; font-weight: 800; }

.messages { overflow-y: auto; padding: 28px max(24px, calc((100% - 900px) / 2)); scroll-behavior: smooth; }
.welcome-card { max-width: 760px; margin: 5vh auto 20px; padding: 28px; text-align: center; border: 1px solid var(--line); border-radius: 20px; background: rgba(29,33,26,.72); }
.welcome-icon { font-size: 38px; }
.welcome-card h2 { margin: 10px 0 6px; font-family: Georgia, serif; }
.welcome-card > p { color: var(--muted); line-height: 1.55; }
.suggestion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.suggestion { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #151812; text-align: left; cursor: pointer; color: var(--muted); }
.suggestion:hover { border-color: rgba(216,169,58,.4); color: var(--ink); }
.message { display: flex; gap: 11px; margin: 0 auto 22px; max-width: 900px; }
.message.user { justify-content: flex-end; }
.avatar { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); }
.message.user .avatar { order: 2; }
.bubble { max-width: min(760px, 85%); padding: 14px 16px; border: 1px solid var(--line); border-radius: 5px 15px 15px 15px; background: var(--panel-2); line-height: 1.57; overflow-wrap: anywhere; }
.message.user .bubble { border-radius: 15px 5px 15px 15px; background: rgba(105,83,32,.25); border-color: rgba(216,169,58,.28); }
.bubble strong { color: var(--gold-light); }
.message-meta { margin-top: 10px; color: #7f7967; font-size: 10px; }
.message.user .message-meta { text-align: right; }
.source-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 9px; }
.source-box summary { cursor: pointer; color: var(--gold-light); font-size: 12px; font-weight: 700; }
.source-item { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.18); color: var(--muted); font-size: 11px; }
.source-item b { display: block; color: var(--ink); margin-bottom: 3px; }
.bubble a, .source-item a { color: var(--gold-light); text-decoration: underline; text-underline-offset: 2px; }
.source-item a { display: block; margin-bottom: 3px; font-weight: 800; }
.typing .bubble { color: var(--muted); }
.typing-dots span { display: inline-block; animation: pulse 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 14px max(24px, calc((100% - 900px) / 2)) 17px; border-top: 1px solid var(--line); background: rgba(15,17,13,.96); }
.composer textarea { resize: none; max-height: 180px; padding: 13px 15px; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; outline: none; background: #181b15; line-height: 1.45; }
.composer textarea:focus { border-color: rgba(216,169,58,.55); }
.composer button { width: 48px; border: 0; border-radius: 13px; cursor: pointer; color: #241b08; background: linear-gradient(135deg, var(--gold-light), var(--gold)); font-size: 21px; }
.composer p { grid-column: 1 / -1; margin: -2px 4px 0; color: #716b5b; font-size: 10px; text-align: center; }

.admin-dialog { width: min(94vw, 610px); color: var(--ink); border: 1px solid rgba(216,169,58,.3); border-radius: 18px; background: #181b15; box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(3px); }
.news-dialog {
  width: min(94vw, 760px);
  max-height: min(90vh, 850px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  border: 1px solid rgba(216,169,58,.34);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 5%, rgba(216,169,58,.14), transparent 31%),
    linear-gradient(145deg, #20251c, #11150f);
  box-shadow: 0 35px 110px rgba(0,0,0,.62);
}
.news-dialog::backdrop { background: rgba(4,6,4,.84); backdrop-filter: blur(8px); }
.news-hero { display: flex; align-items: center; gap: 17px; padding: 26px 28px 21px; border-bottom: 1px solid rgba(216,169,58,.14); }
.news-seal { flex: 0 0 62px; width: 62px; height: 62px; display: grid; place-items: center; border: 1px solid rgba(216,169,58,.35); border-radius: 18px; background: rgba(216,169,58,.1); font-size: 31px; box-shadow: inset 0 0 0 5px rgba(216,169,58,.035); }
.news-hero h2 { margin: 3px 0 5px; font: 30px/1.05 Georgia, serif; }
.news-hero p { margin: 0; color: var(--muted); font-size: 12px; }
.news-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 17px 28px 5px; }
.news-stats > div { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; padding: 12px; border: 1px solid rgba(255,255,255,.07); border-radius: 13px; background: rgba(0,0,0,.17); }
.news-stats span { grid-row: 1 / 3; align-self: center; font-size: 22px; }
.news-stats b { color: var(--gold-light); font-size: 15px; }
.news-stats small { color: #807967; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.news-section { padding: 18px 28px 0; }
.news-section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.news-section-title h3 { margin: 0; font: 17px Georgia, serif; }
.news-section-title span { color: #817b69; font-size: 10px; }
.news-book-list { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.news-book { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 11px; border: 1px solid rgba(255,255,255,.06); border-radius: 11px; background: rgba(6,9,6,.22); }
.news-book > span { flex: 0 0 30px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: rgba(216,169,58,.08); }
.news-book div { min-width: 0; }
.news-book b { display: block; overflow: hidden; color: #ddd4b8; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.news-book small { display: block; margin-top: 2px; color: #746f60; font-size: 9px; }
.errata-news > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.news-status { margin-top: 10px; padding: 10px 12px; color: #aaa38e; border: 1px solid rgba(255,255,255,.07); border-radius: 10px; background: rgba(0,0,0,.18); font-size: 10px; line-height: 1.5; }
.news-status.pending { color: #e5c879; border-color: rgba(216,169,58,.2); background: rgba(216,169,58,.055); }
.news-status.approved { color: #a8d2a9; border-color: rgba(110,170,111,.22); background: rgba(110,170,111,.06); }
.news-actions { display: flex; justify-content: flex-end; padding: 19px 28px 25px; }
.news-actions .primary-button { min-width: 210px; }
.feedback-dialog {
  width: min(96vw, 920px);
  max-height: 91vh;
  padding: 0;
  overflow: auto;
  color: var(--ink);
  border: 1px solid rgba(208,107,98,.3);
  border-radius: 22px;
  background:
    radial-gradient(circle at 94% 2%, rgba(176,62,51,.12), transparent 28%),
    #171b15;
  box-shadow: 0 32px 100px rgba(0,0,0,.66);
}
.feedback-dialog::backdrop { background: rgba(3,5,3,.82); backdrop-filter: blur(7px); }
.feedback-head { position: sticky; z-index: 2; top: 0; padding: 22px 24px 16px; border-bottom: 1px solid rgba(255,255,255,.07); background: rgba(23,27,21,.96); backdrop-filter: blur(8px); }
.feedback-head h2 { margin: 4px 0 0; }
.feedback-tabs { display: flex; gap: 7px; padding: 14px 24px 0; }
.feedback-tabs button { padding: 8px 11px; color: #8f8876; border: 1px solid rgba(255,255,255,.07); border-radius: 9px; background: rgba(0,0,0,.13); cursor: pointer; font-size: 10px; }
.feedback-tabs button.active { color: #251b08; border-color: transparent; background: linear-gradient(135deg, var(--gold-light), var(--gold)); font-weight: 800; }
.feedback-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 24px 8px; }
.feedback-counters { display: flex; flex-wrap: wrap; gap: 7px; }
.feedback-counters span { padding: 6px 9px; color: #8e8774; border: 1px solid rgba(255,255,255,.07); border-radius: 999px; background: rgba(0,0,0,.15); font-size: 10px; }
.feedback-counters b { color: var(--gold-light); }
.feedback-toolbar label { color: #817a68; font-size: 10px; }
.feedback-toolbar select { margin-left: 5px; padding: 6px 8px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; background: #11140f; }
.feedback-search { display: flex; align-items: center; gap: 8px; margin: 2px 24px 11px; padding: 8px 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 10px; background: rgba(0,0,0,.16); }
.feedback-search input { min-width: 0; flex: 1; color: var(--ink); border: 0; outline: 0; background: transparent; font-size: 11px; }
.feedback-copy { margin: 4px 24px 14px; color: #777160; font-size: 10px; line-height: 1.5; }
.feedback-case-list { display: grid; gap: 10px; padding: 0 24px 8px; }
.feedback-case { padding: 15px; border: 1px solid rgba(255,255,255,.075); border-left: 3px solid #b45043; border-radius: 13px; background: rgba(7,10,7,.25); }
.feedback-case.reviewed { border-left-color: #d0a643; }
.feedback-case.resolved { border-left-color: #679a69; opacity: .82; }
.feedback-case.history { border-left-color: #5d7e9b; }
.feedback-case-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.feedback-case-head b { display: block; font-size: 12px; }
.feedback-case-head small { display: block; margin-top: 3px; color: #746e5e; font-size: 9px; }
.case-status { align-self: flex-start; padding: 4px 7px; color: #eab0a9; border: 1px solid rgba(208,107,98,.25); border-radius: 999px; font-size: 9px; font-weight: 800; }
.case-status.reviewed { color: #e3c578; border-color: rgba(216,169,58,.25); }
.case-status.resolved { color: #91c294; border-color: rgba(110,170,111,.25); }
.case-status.unrated { color: #9eb4c7; border-color: rgba(93,126,155,.28); }
.case-status.delivered { color: #91c294; border-color: rgba(110,170,111,.25); }
.case-status.not-delivered { color: #eab0a9; border-color: rgba(208,107,98,.25); }
.feedback-case h4 { margin: 9px 0 4px; color: #a9a18b; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.feedback-case p { margin: 0; color: #d0c7ab; font-size: 11px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-case .feedback-answer { max-height: 145px; padding: 9px; overflow: auto; color: #9e9784; border-radius: 8px; background: rgba(0,0,0,.16); }
.feedback-case-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.feedback-case-actions button { padding: 7px 9px; color: #aaa28c; border: 1px solid rgba(255,255,255,.08); border-radius: 8px; background: #1c2119; cursor: pointer; font-size: 9px; }
.feedback-case-actions button:hover { color: var(--ink); border-color: rgba(216,169,58,.3); }
.feedback-case-actions .case-copy { margin-right: auto; color: var(--gold-light); }
.feedback-empty { padding: 30px; color: #8eb390; border: 1px dashed rgba(110,170,111,.2); border-radius: 12px; text-align: center; font-size: 12px; }
.feedback-footer { display: flex; justify-content: flex-end; padding: 10px 24px 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-family: Georgia, serif; }
.dialog-head button { border: 0; background: transparent; cursor: pointer; color: var(--muted); }
.dialog-copy { color: var(--muted); line-height: 1.5; }
.mode-options { display: grid; gap: 8px; margin: 18px 0; }
.mode-options label { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.mode-options label:has(input:checked) { border-color: rgba(216,169,58,.55); background: rgba(216,169,58,.07); }
.mode-options b, .switch-row b { display: block; margin-bottom: 3px; }
.mode-options span { color: var(--muted); font-size: 12px; }
.mode-options b { color: var(--ink); font-size: 13px; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.switch-row small { display: block; color: var(--muted); }
.provider-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.provider-pill { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(85vw, 310px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .icon-button { display: block; }
  .chat-header { padding: 12px 14px; }
  .chat-header p { display: none; }
  .provider-badge { padding: 6px 8px; max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .messages { padding: 18px 12px; }
  .composer { padding: 11px 12px; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .welcome-card { padding: 20px 16px; }
  .bubble { max-width: 88%; }
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .chat-header h1 { max-width: 170px; font-size: 17px; }
  .provider-badge { font-size: 9px; }
  .avatar { display: none; }
  .bubble { max-width: 94%; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
  .news-dialog { max-height: 92vh; border-radius: 19px; }
  .news-hero { padding: 20px 17px 16px; }
  .news-seal { flex-basis: 49px; width: 49px; height: 49px; border-radius: 14px; font-size: 24px; }
  .news-hero h2 { font-size: 24px; }
  .news-stats { grid-template-columns: 1fr; padding: 13px 17px 0; }
  .news-section { padding: 16px 17px 0; }
  .news-book-list { grid-template-columns: 1fr; }
  .news-actions { padding: 17px; }
  .news-actions .primary-button { width: 100%; }
  .feedback-dialog { max-height: 94vh; border-radius: 17px; }
  .feedback-head { padding: 18px 15px 13px; }
  .feedback-tabs { padding: 12px 15px 0; overflow-x: auto; }
  .feedback-tabs button { white-space: nowrap; }
  .feedback-toolbar { align-items: flex-start; flex-direction: column; padding: 14px 15px 7px; }
  .feedback-search { margin: 2px 15px 10px; }
  .feedback-copy { margin: 4px 15px 12px; }
  .feedback-case-list { padding: 0 15px 6px; }
  .feedback-case-head { flex-direction: column; }
  .case-status { align-self: flex-start; }
  .feedback-case-actions .case-copy { width: 100%; margin-right: 0; }
  .feedback-footer { padding: 10px 15px 17px; }
  .feedback-footer button { width: 100%; }
}

/* Codex UI refresh */
.app-page {
  background:
    radial-gradient(circle at 78% -10%, rgba(230, 180, 62, .13), transparent 33%),
    radial-gradient(circle at 8% 95%, rgba(88, 148, 100, .11), transparent 30%),
    #0b0e0a;
}
.arcane-sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.arcane-sky::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .22;
  background-image:
    radial-gradient(circle, rgba(250, 222, 130, .42) 0 1px, transparent 1.5px),
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 83px 83px, 32px 32px, 32px 32px;
}
.arcane-sky span { position: absolute; border: 1px solid rgba(219, 175, 65, .1); border-radius: 50%; }
.arcane-sky span:nth-child(1) { width: 390px; height: 390px; right: -150px; top: 7%; }
.arcane-sky span:nth-child(2) { width: 250px; height: 250px; right: -80px; top: calc(7% + 70px); border-style: dashed; }
.arcane-sky span:nth-child(3) { width: 310px; height: 310px; left: -170px; bottom: -80px; }
.app-shell { position: relative; z-index: 1; }
.sidebar {
  border-right-color: rgba(225, 187, 90, .17);
  background:
    linear-gradient(180deg, rgba(28, 32, 23, .97), rgba(12, 16, 12, .98)),
    #11140f;
  box-shadow: inset -1px 0 rgba(255,255,255,.02);
}
.brand-mark {
  box-shadow: inset 0 0 0 5px rgba(216,169,58,.045), 0 8px 22px rgba(0,0,0,.25);
  animation: seal-breathe 4s ease-in-out infinite;
}
.library-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  margin: -4px 4px 13px;
  padding: 8px 9px;
  color: #9fbea0;
  border: 1px solid rgba(110,170,111,.16);
  border-radius: 10px;
  background: rgba(74, 126, 76, .065);
  font-size: 10px;
}
.library-status i { width: 7px; height: 7px; border-radius: 50%; background: #79c47c; box-shadow: 0 0 12px rgba(121,196,124,.7); }
.library-status b { color: #667466; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.oath-mini { margin: 1px 5px 8px; color: #777361; font-size: 10px; line-height: 1.4; }
.new-thread-button {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(216,169,58,.15), rgba(121,97,34,.07));
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.new-thread-button::after { content: ""; position: absolute; inset: 0; transform: translateX(-110%); background: linear-gradient(90deg, transparent, rgba(255,239,180,.09), transparent); transition: transform .45s ease; }
.new-thread-button:hover::after { transform: translateX(110%); }
.chat-panel { background: rgba(14, 17, 13, .82); backdrop-filter: blur(3px); }
.chat-header {
  border-color: rgba(225, 187, 90, .14);
  background: linear-gradient(90deg, rgba(14,17,13,.97), rgba(25,28,20,.91));
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.header-copy { min-width: 0; display: flex; align-items: center; gap: 10px; }
.header-rune { display: grid; place-items: center; width: 34px; height: 34px; color: var(--gold-light); border: 1px solid rgba(216,169,58,.25); border-radius: 10px; background: rgba(216,169,58,.07); }
.provider-badge { border-color: rgba(216,169,58,.22); background: linear-gradient(135deg, rgba(216,169,58,.08), rgba(255,255,255,.02)); box-shadow: inset 0 1px rgba(255,255,255,.035); }
.messages {
  background-image:
    linear-gradient(90deg, transparent 49.8%, rgba(216,169,58,.025) 50%, transparent 50.2%),
    radial-gradient(circle at 50% 40%, rgba(216,169,58,.035), transparent 38%);
}
.welcome-card {
  max-width: 900px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(235px, .92fr);
  align-items: center;
  gap: 4px 18px;
  margin-top: clamp(16px, 4vh, 48px);
  padding: 30px 30px 24px;
  text-align: left;
  border-color: rgba(216,169,58,.23);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(34,39,29,.93), rgba(18,22,16,.91)),
    var(--panel-2);
  box-shadow: 0 28px 80px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.035);
  overflow: hidden;
  position: relative;
}
.welcome-card::before {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  right: -80px;
  top: -100px;
  border: 1px solid rgba(216,169,58,.1);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(216,169,58,.018), 0 0 0 68px rgba(216,169,58,.012);
}
.welcome-copy { position: relative; z-index: 1; padding: 5px 0 10px; }
.welcome-copy .eyebrow { display: inline-block; margin-bottom: 8px; }
.welcome-card h2 { margin: 3px 0 10px; max-width: 500px; font-size: clamp(28px, 3vw, 43px); line-height: 1.08; text-wrap: balance; }
.welcome-card .welcome-copy > p { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.62; }
.welcome-art { position: relative; z-index: 1; align-self: stretch; display: grid; place-items: center; min-height: 235px; }
.welcome-art img { width: min(100%, 335px); max-height: 275px; filter: drop-shadow(0 20px 28px rgba(0,0,0,.35)); animation: codex-float 5.5s ease-in-out infinite; }
.welcome-traits { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.welcome-traits span { padding: 7px 9px; color: #cbc2a6; border: 1px solid rgba(216,169,58,.17); border-radius: 999px; background: rgba(8,10,7,.24); font-size: 10px; font-weight: 700; }
.suggestion-grid { position: relative; z-index: 1; grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 12px; }
.suggestion {
  min-height: 88px;
  padding: 13px;
  border-color: rgba(255,255,255,.075);
  background: linear-gradient(145deg, rgba(9,12,8,.45), rgba(32,37,27,.6));
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.suggestion b { display: block; margin-bottom: 7px; color: var(--ink); font-size: 12px; }
.suggestion span { display: block; color: #938b75; font-size: 11px; line-height: 1.35; }
.suggestion:hover { transform: translateY(-3px); border-color: rgba(216,169,58,.4); background: rgba(216,169,58,.06); }
.message { animation: message-rise .22s ease both; }
.avatar { border-color: rgba(216,169,58,.2); background: linear-gradient(145deg, #252a20, #151812); box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.message.assistant .avatar { color: var(--gold-light); }
.bubble {
  border-color: rgba(255,255,255,.085);
  background: linear-gradient(145deg, rgba(31,36,27,.97), rgba(23,27,20,.97));
  box-shadow: 0 10px 30px rgba(0,0,0,.13), inset 0 1px rgba(255,255,255,.025);
}
.message.user .bubble { background: linear-gradient(145deg, rgba(112,87,31,.3), rgba(66,56,26,.2)); }
.message-body p { margin: 0 0 .72em; }
.message-body p:last-child { margin-bottom: 0; }
.message-body ul, .message-body ol { margin: .5em 0 .8em; padding-left: 1.35em; }
.message-body li { margin: .28em 0; }
.message-body h3, .message-body h4 { margin: 1.05em 0 .42em; color: var(--gold-light); font-family: Georgia, serif; }
.message-body code { padding: 2px 5px; border: 1px solid rgba(216,169,58,.15); border-radius: 5px; background: rgba(0,0,0,.25); }
.table-scroll { max-width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid rgba(216,169,58,.14); border-radius: 11px; }
.message-body table { width: 100%; border-collapse: collapse; min-width: 430px; font-size: 12px; }
.message-body th { color: #231b09; background: linear-gradient(135deg, #ead06f, #c89a31); text-align: left; }
.message-body th, .message-body td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,.065); vertical-align: top; }
.message-body tr:last-child td { border-bottom: 0; }
.message-body tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
.source-box { border-color: rgba(216,169,58,.13); }
.source-item { border: 1px solid rgba(255,255,255,.045); }
.message-feedback {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(216,169,58,.1);
}
.message-feedback > span { color: #8a8370; font-size: 10px; }
.message-feedback > div { display: flex; gap: 5px; }
.message-feedback button {
  padding: 5px 8px;
  color: #9e9783;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
  cursor: pointer;
  font-size: 10px;
}
.message-feedback button:hover { color: var(--ink); border-color: rgba(216,169,58,.26); }
.message-feedback button.selected { color: #241b08; border-color: transparent; background: linear-gradient(135deg, var(--gold-light), var(--gold)); font-weight: 800; }
.feedback-result { grid-column: 1 / -1; min-height: 12px; color: #706a5a; font-size: 9px; }
.feedback-result.positive { color: #83b986; }
.feedback-result.negative { color: #e0ad66; }
.composer {
  display: block;
  padding-top: 11px;
  border-color: rgba(216,169,58,.15);
  background: linear-gradient(180deg, rgba(12,15,11,.97), rgba(17,20,15,.99));
  box-shadow: 0 -18px 44px rgba(0,0,0,.18);
}
.model-picker { display: flex; align-items: center; gap: 8px; margin: 0 3px 8px; min-width: 0; }
.model-picker label { color: var(--gold-light); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.model-picker select {
  min-width: 0;
  max-width: 410px;
  padding: 6px 30px 6px 9px;
  color: #d7cdaa;
  border: 1px solid rgba(216,169,58,.18);
  border-radius: 9px;
  outline: 0;
  background: #171b14;
  font-size: 10px;
  cursor: pointer;
}
.model-picker select:focus { border-color: rgba(216,169,58,.55); box-shadow: 0 0 0 3px rgba(216,169,58,.08); }
.model-picker option:disabled { color: #665f4e; }
.model-picker > span { color: #6f6a59; font-size: 9px; white-space: nowrap; }
.composer-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.composer-row textarea { min-height: 50px; box-shadow: inset 0 1px 10px rgba(0,0,0,.18); }
.composer-row button { position: relative; width: 51px; min-height: 50px; overflow: hidden; box-shadow: 0 8px 25px rgba(190,139,25,.18); }
.composer-row button span { display: inline-block; transition: transform .18s ease; }
.composer-row button:hover span { transform: translate(2px, -2px); }
.composer > p { margin: 6px 4px 0; }
.quill { display: inline-block; animation: quill-write .8s ease-in-out infinite alternate; }

@keyframes seal-breathe { 0%, 100% { box-shadow: inset 0 0 0 5px rgba(216,169,58,.045), 0 8px 22px rgba(0,0,0,.25); } 50% { box-shadow: inset 0 0 0 5px rgba(216,169,58,.08), 0 0 24px rgba(216,169,58,.12); } }
@keyframes codex-float { 0%, 100% { transform: translateY(0) rotate(-.4deg); } 50% { transform: translateY(-8px) rotate(.4deg); } }
@keyframes message-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes quill-write { from { transform: translateX(-2px) rotate(-4deg); } to { transform: translateX(2px) rotate(3deg); } }

@media (max-width: 1000px) {
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .header-copy { gap: 7px; }
  .header-rune { display: none; }
  .welcome-card { grid-template-columns: 1fr; margin-top: 0; padding: 23px 18px 18px; }
  .welcome-art { min-height: 170px; order: -1; }
  .welcome-art img { max-height: 190px; }
  .welcome-card h2 { font-size: 31px; }
  .suggestion-grid { grid-column: 1; }
  .model-picker > span { display: none; }
  .model-picker select { flex: 1; max-width: none; }
}

@media (max-width: 480px) {
  .welcome-art { min-height: 145px; }
  .welcome-art img { max-height: 165px; }
  .welcome-card h2 { font-size: 27px; }
  .welcome-traits span:nth-child(3) { display: none; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion { min-height: auto; }
  .model-picker label { font-size: 0; }
  .model-picker label::after { content: "🪄"; font-size: 14px; }
  .model-picker select { width: calc(100% - 25px); }
  .message-feedback { grid-template-columns: 1fr; }
  .message-feedback > div { justify-content: flex-start; }
  .feedback-result { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
