@import url('/uniform-theme.css');
@import url("https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400;500&display=swap");

:root {
  --navy:        #0d1b2a;
  --navy-mid:    #1a2d45;
  --gold:        #c9a84c;
  --gold-light:  #e8c97a;
  --green:       #2d9b6f;
  --red:         #c0392b;

  --bg:          #faf8f4;
  --bg-card:     #ffffff;
  --border:      #d4cbbe;
  --border-light:#ede8e0;
  --input-bg:    #f5f2ec;

  --text:        #0d1b2a;
  --text-2:      #4a5568;
  --text-muted:  #718096;

  --shadow:      0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.08);

  --radius:      12px;
  --radius-sm:   7px;

  --fh: 'Syne', sans-serif;
  --fb: 'DM Sans', sans-serif;
  --fm: 'DM Mono', monospace;
}

/* ── Dark mode ──────────────────────────────── */

[data-theme="dark"] {
  --bg:          #07101c;
  --bg-card:     #0c1927;
  --border:      rgba(201,168,76,0.22);
  --border-light:rgba(201,168,76,0.12);
  --input-bg:    #0a1520;
  --text:        #ede7db;
  --text-2:      rgba(237,231,219,0.65);
  --text-muted:  rgba(237,231,219,0.38);
  --shadow:      0 2px 12px rgba(0,0,0,0.45), 0 1px 4px rgba(0,0,0,0.35);
  --shadow-md:   0 6px 20px rgba(0,0,0,0.50);
}

/* ── Transitions ────────────────────────────── */

body, .card, .page-header, .chat-topbar, .chat-messages,
.chat-input, .chat-input-row, .token-box, .info,
.msg-bubble, .btn, input[type="text"] {
  transition: background-color 0.22s ease, border-color 0.22s ease,
              color 0.22s ease, box-shadow 0.22s ease;
}

/* ── Theme toggle button ────────────────────── */

.theme-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}

.theme-btn:hover {
  background: rgba(201,168,76,0.18);
  border-color: rgba(201,168,76,0.45);
  color: var(--gold-light);
  transform: rotate(18deg);
}

.header-actions {
  position: absolute; top: 14px; right: 22px; z-index: 10;
  display: flex; align-items: center; gap: 8px;
}

.home-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.72);
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex; align-items: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.home-btn:hover { background: rgba(201,168,76,0.18); border-color: rgba(201,168,76,0.45); color: var(--gold-light); }

.lang-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: inline-flex; align-items: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.lang-btn:hover { background: rgba(201,168,76,0.18); border-color: rgba(201,168,76,0.45); color: var(--gold-light); }
[data-theme="dark"] .lang-btn:hover { background: rgba(201,168,76,0.14); color: var(--gold-light); }

.ico-moon { display: block; }
.ico-sun  { display: none;  }
[data-theme="dark"] .ico-moon { display: none;  }
[data-theme="dark"] .ico-sun  { display: block; }

/* ── Dark overrides ─────────────────────────── */

[data-theme="dark"] .page-header {
  background: linear-gradient(135deg, #06101d 0%, #0d1b2a 100%);
}

[data-theme="dark"] .theirs .msg-bubble {
  background: #0f2035;
  border-color: rgba(201,168,76,0.15);
  color: var(--text);
}

[data-theme="dark"] .sys-msg {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
}

[data-theme="dark"] .info.note {
  background: rgba(201,168,76,0.08);
  border-color: rgba(201,168,76,0.22);
  color: var(--gold-light);
}

[data-theme="dark"] .info.ok {
  background: rgba(45,155,111,0.1);
  color: #5ecba0;
}

[data-theme="dark"] .info.err {
  background: rgba(192,57,43,0.1);
  color: #e07070;
}

[data-theme="dark"] .token-box {
  background: rgba(255,255,255,0.03);
}

[data-theme="dark"] .copy-btn {
  background: transparent;
  border-color: rgba(201,168,76,0.2);
  color: var(--text-muted);
}

[data-theme="dark"] .copy-btn:hover {
  border-color: rgba(201,168,76,0.5);
  color: var(--gold-light);
}

[data-theme="dark"] .btn {
  background: #162234;
  border-color: rgba(201,168,76,0.2);
  color: var(--text);
}

[data-theme="dark"] .btn:hover {
  background: #1c2e44;
  border-color: rgba(201,168,76,0.35);
}

[data-theme="dark"] .btn-primary {
  background: #1a2d45;
  border-color: rgba(201,168,76,0.3);
  color: var(--gold-light);
}

[data-theme="dark"] .btn-primary:hover {
  background: #223a56;
  border-color: rgba(201,168,76,0.5);
}

[data-theme="dark"] .footer {
  border-color: rgba(201,168,76,0.1);
  color: rgba(237,231,219,0.3);
}

/* ── Reset ──────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--fb);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-mid); }

/* ── Page header ──────────────────────────────── */

.page-header {
  background: var(--navy);
  color: white;
  padding: 44px 0 38px;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: rgba(201,168,76,0.08);
}

.page-header::after {
  content: '';
  position: absolute;
  bottom: -80px; left: 42%;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(45,155,111,0.05);
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(201,168,76,0.15);
  border: 1px solid rgba(201,168,76,0.3);
  color: var(--gold-light);
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.page-header h1 {
  font-family: var(--fh);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: white;
  margin-bottom: 8px;
}

.page-header p {
  color: rgba(255,255,255,0.5);
  font-size: 13.5px;
}

/* ── Container ──────────────────────────────── */

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Card ───────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 24px;
  margin-bottom: 18px;
}

/* ── Section heading ────────────────────────── */

.sh {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.sn {
  width: 22px; height: 22px;
  background: var(--navy);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--fh);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.st {
  font-family: var(--fh);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Forms ──────────────────────────────────── */

input[type="text"] {
  width: 100%;
  padding: 10px 13px;
  font-family: var(--fb);
  font-size: 0.93rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  transition: border-color .15s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--navy);
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.form-row input { flex: 1; }

/* ── Buttons ────────────────────────────────── */

.btn {
  font-family: var(--fh);
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: .03em;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(13,27,42,0.22);
  background: #eee8de;
  color: var(--navy);
  padding: 10px 20px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover {
  background: #e4ddd2;
  border-color: rgba(13,27,42,0.32);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: white;
  border-color: transparent;
}

.btn-primary:hover { background: var(--navy-mid); }

.btn-sm {
  font-size: 0.8rem;
  padding: 7px 14px;
}

/* ── Token display ──────────────────────────── */

.token-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.token-label {
  font-family: var(--fh);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}

.token-value {
  font-family: var(--fm);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: .06em;
  flex: 1;
  word-break: break-all;
}

.copy-btn {
  font-family: var(--fh);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text-muted);
  padding: 5px 12px;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}

.copy-btn:hover { color: var(--navy); border-color: var(--navy); }
.copy-btn.copied {
  color: #1a6b47;
  border-color: rgba(45,155,111,0.4);
  background: rgba(45,155,111,0.06);
}

/* ── Status dots ────────────────────────────── */

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.88rem;
  color: var(--text-2);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}

.status-dot.waiting { background: var(--gold); box-shadow: 0 0 0 4px rgba(201,168,76,0.2); }
.status-dot.live    { background: var(--green); box-shadow: 0 0 0 4px rgba(45,155,111,0.18); }

/* ── Info boxes ─────────────────────────────── */

.info {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  line-height: 1.5;
}

.info.ok   { background: rgba(45,155,111,0.08);  border: 1px solid rgba(45,155,111,0.25); color: #1a6b47; }
.info.err  { background: rgba(192,57,43,0.07);   border: 1px solid rgba(192,57,43,0.2);  color: var(--red); }
.info.note { background: rgba(201,168,76,0.10);  border: 1px solid rgba(201,168,76,0.3); color: #7a5a10; }

/* ── Chat page layout ───────────────────────── */

body.chat-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.chat-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.chat-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-topbar-title {
  font-family: var(--fh);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: white;
}

.chat-topbar-sub {
  font-family: var(--fm);
  font-size: 0.78rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: .04em;
}

.role-pill {
  font-family: var(--fh);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(201,168,76,0.15);
  border: 1px solid rgba(201,168,76,0.3);
  color: var(--gold-light);
  flex-shrink: 0;
}

.chat-topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
}

.chat-topbar-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  transition: background .3s, box-shadow .3s;
}

.chat-topbar-dot.live {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(45,155,111,0.25);
}

.chat-body-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 12px;
  gap: 8px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Messages area */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.msg-wrap.mine   { align-self: flex-end;   align-items: flex-end; }
.msg-wrap.theirs { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 0.93rem;
  line-height: 1.5;
  word-break: break-word;
}

.mine   .msg-bubble {
  background: var(--navy);
  color: white;
  border-bottom-right-radius: 4px;
}

.theirs .msg-bubble {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}

.msg-bubble.err {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  border: 1px solid var(--border-light);
  border-radius: 10px;
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 2px;
}

.sys-msg {
  align-self: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.04);
  border-radius: 20px;
  padding: 3px 12px;
  margin: 4px 0;
}

/* Input area */

.chat-input-row {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--fb);
  font-size: 0.93rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .15s;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
}

.chat-input:focus { outline: none; border-color: var(--navy); }

/* ── Footer ─────────────────────────────────── */

.footer {
  text-align: center;
  padding: 20px 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-light);
}

/* ── Responsive ─────────────────────────────── */

@media (max-width: 600px) {
  .container { padding: 20px 16px 48px; }
  .page-header { padding: 28px 0 24px; }
  .header-actions { top: 10px; right: 14px; }
  .card { padding: 20px 16px; }
  .msg-wrap { max-width: 86%; }
  .chat-topbar { padding: 8px 14px; }
  .chat-topbar-sub { display: none; }
  .chat-body-wrap { padding: 8px; }
}
