body {
  font-family: Arial, sans-serif;
  background: #0b1224;
  color: #e5e7eb;
  margin: 0;
  padding: clamp(16px, 2vw, 28px);
  font-size: clamp(14px, 1.2vw, 16px);
}
.page { width: min(1600px, 98vw); margin: 0 auto; }
.page h1 { font-size: clamp(28px, 3vw, 44px); margin: 0 0 20px; letter-spacing: 0.2px; }
.card { background: #0f172a; border: 1px solid #1f2a44; border-radius: 16px; padding: clamp(18px, 2vw, 28px); margin-bottom: 18px; }
.card h3 { margin-top: 0; font-size: clamp(18px, 2vw, 26px); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
input, textarea, button { padding: 10px; border-radius: 8px; border: 1px solid #1f2a44; background: #0d1a33; color: #e5e7eb; }
textarea { width: 100%; resize: vertical; min-height: 240px; line-height: 1.55; font-size: 1rem; }
button { cursor: pointer; background: linear-gradient(90deg,#38bdf8,#f97316); border: none; font-weight: bold; font-size: clamp(14px, 1.3vw, 17px); }
.ghost { background: transparent; border: 1px solid #1f2a44; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.box { min-height: 60px; padding: 10px; border: 1px dashed #1f2a44; border-radius: 8px; }
.muted { color: #9ca3af; }
.warn { color: #fbbf24; margin-top: 8px; }
.helper { color: #9ca3af; margin: 6px 0 10px; }
.error { color: #f87171; }
.hidden { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 1rem; }
th, td { border: 1px solid #1f2a44; padding: 10px 8px; text-align: left; vertical-align: top; }
thead th { text-align: center; background: rgba(13, 26, 51, 0.65); font-size: clamp(13px, 1.2vw, 16px); }
tbody td:first-child { text-align: center; font-weight: 800; color: #cbd5e1; }

.layout { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.main-col { order: 1; }
.account-col { order: 2; position: sticky; top: 18px; }

.account-col #login-card .row { flex-direction: column; align-items: stretch; }
.account-col #login-card input, .account-col #login-card button { width: 100%; }

.account-col #login-status { margin-top: 8px; }

.account-meta { margin-top: 12px; padding-top: 12px; border-top: 1px solid #1f2a44; }
.meta-row { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; margin: 8px 0; }
.strong { font-weight: 800; color: #e5e7eb; }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-weight: 900; letter-spacing: 0.2px; background: rgba(56,189,248,0.15); border: 1px solid rgba(56,189,248,0.45); color: #bae6fd; }
.badge.paid { background: rgba(249,115,22,0.12); border-color: rgba(249,115,22,0.45); color: #fed7aa; }
.badge.expired { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.5); color: #fecaca; }

.account-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.account-tabs .tab { flex: 1; justify-content: center; }
.acct-panel { display: none; }
.acct-panel.active { display: block; }
.account-status { margin-top: 12px; }

.field { display: block; margin-bottom: 12px; }
.field-label { display: block; font-weight: 800; margin-bottom: 6px; color: #cbd5e1; }
.field input { width: 100%; padding: 16px 14px; font-size: 1.15rem; border-radius: 12px; }
.field-help { margin-top: 6px; color: #9ca3af; font-size: 14px; line-height: 1.4; }
.field-error { margin-top: 6px; color: #f87171; font-size: 14px; min-height: 18px; }
.form-link { margin-top: 10px; color: #9ca3af; font-size: 14px; }
.link-btn { background: transparent; border: none; padding: 0; color: #38bdf8; font-weight: 800; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.password-field { display: flex; align-items: center; gap: 8px; }
.password-field input { flex: 1; }
.eye-btn { width: 46px; min-width: 46px; padding: 8px; font-size: 16px; background: #0d1a33; border: 1px solid #1f2a44; border-radius: 10px; cursor: pointer; }
.forgot { margin: 10px 0; padding: 10px; border: 1px dashed #1f2a44; border-radius: 10px; }

.account-col button:disabled { opacity: 0.7; cursor: not-allowed; }

.usage { margin: 10px 0 12px; }
.usage-row { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.usage-bar { margin-top: 8px; height: 10px; border-radius: 999px; background: rgba(13, 26, 51, 0.85); border: 1px solid #1f2a44; overflow: hidden; }
.usage-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#38bdf8,#f97316); }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; background: #0d1a33; border: 1px solid #1f2a44; color: #e5e7eb; padding: 10px 14px; border-radius: 999px; font-weight: 800; font-size: 1rem; }
.tab.active { background: linear-gradient(90deg,#38bdf8,#f97316); border: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.sentence-block { margin-bottom: 12px; }
.sentence-title { font-weight: 700; margin-bottom: 8px; color: #cbd5e1; }
.highlight-line { display: flex; flex-wrap: wrap; gap: 4px; line-height: 1.8; }
.token-chip { padding: 2px 6px; border-radius: 10px; border: 1px solid #1f2a44; background: #0d1a33; }
.entity { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(20,184,166,0.15); border: 1px solid rgba(20,184,166,0.55); }
.entity .tag { font-size: 12px; font-weight: 800; color: #0b1224; background: var(--color, #14b8a6); padding: 1px 8px; border-radius: 999px; }

/* Make the first landing card easier to read */
#prelogin-card .muted { font-size: 19px; line-height: 1.75; }
#prelogin-card .muted p { margin: 10px 0; }
#prelogin-card, #login-card { padding: clamp(20px, 2vw, 32px); }
#login-card input { min-width: 220px; }

.account-col #logout-btn { margin-top: 10px; }
.account-actions { margin-top: 12px; }

/* When logged out, center the account card under Welcome to give more room for larger fonts. */
body:not(.authed) .layout { grid-template-columns: 1fr; }
body:not(.authed) .account-col { position: static; max-width: 560px; margin: 0 auto; order: 2; }

/* Force-hide auth form when logged in, even if JS timing glitches */
body.authed .loggedout-only { display: none !important; }
body.authed #account-status { display: block !important; }

.status-message { margin-top: 8px; font-weight: 600; }
.status-message.info { color: #38bdf8; }
.status-message.success { color: #22c55e; }
.status-message.error { color: #f87171; }
.sentence-block { margin-bottom: 14px; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .main-col { order: 2; }
  .account-col { order: 1; position: static; top: auto; }
  .page { max-width: 980px; }
}
