:root {
  color-scheme: light;
  --ink: #16201a;
  --muted: #69746d;
  --paper: #fffaf1;
  --canvas: #f1e7d6;
  --panel: #fffdf8;
  --line: #ded2bd;
  --green: #0d5f46;
  --green-2: #0f8b63;
  --blue: #1c4f82;
  --terracotta: #a64f32;
  --danger: #b42318;
  --shadow: 0 28px 80px rgba(51, 39, 22, .16);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, Segoe UI, Arial, sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-body { background: linear-gradient(90deg, rgba(13,95,70,.08) 1px, transparent 1px), linear-gradient(180deg, #f8f1e6, #efe0cc); background-size: 38px 38px, auto; }
.app-shell { width: min(1480px, calc(100% - 32px)); margin: 0 auto; padding: 18px 0 38px; }
.topbar { position: sticky; top: 12px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; padding: 12px 14px; border: 1px solid rgba(222, 210, 189, .9); border-radius: 22px; background: rgba(255, 253, 248, .88); box-shadow: 0 18px 54px rgba(51, 39, 22, .12); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--ink); color: #f7ecd9; font-weight: 950; letter-spacing: -.08em; }
.brand strong { display: block; font-size: 17px; line-height: 1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.session-pill, .ghost-link, .language-button { border: 1px solid var(--line); border-radius: 999px; background: #fffaf1; color: var(--muted); font-size: 12px; font-weight: 800; padding: 9px 12px; }
.ghost-link { color: var(--green); text-decoration: none; }
.language-switcher { position: relative; }
.language-button { display: inline-flex; gap: 8px; align-items: center; color: var(--ink); }
.language-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.language-menu button { display: block; width: 100%; border: 0; border-radius: 12px; background: transparent; color: var(--ink); text-align: left; padding: 10px 12px; }
.language-menu button:hover { background: #f1e7d6; }

.command-center { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(320px, .48fr); align-items: end; gap: 28px; margin: 22px 0; padding: 34px; border-radius: 34px; background: #17201a; color: #fffaf1; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.command-center::after { content: ""; position: absolute; right: -80px; top: -120px; width: 360px; height: 360px; border-radius: 999px; background: radial-gradient(circle, rgba(15,139,99,.55), transparent 66%); }
.command-center > * { position: relative; z-index: 1; }
.eyebrow { margin: 0 0 12px; color: #8ee0bc; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; font-weight: 950; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(42px, 6vw, 86px); line-height: .92; letter-spacing: -.06em; }
.command-center p:not(.eyebrow) { margin: 0; color: #d9e4d9; font-size: 18px; line-height: 1.55; }

.workspace-grid { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 253, 248, .94); box-shadow: var(--shadow); }
.tool-panel { position: sticky; top: 100px; display: grid; gap: 16px; padding: 20px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 15px; background: #fffaf1; color: var(--ink); outline: none; padding: 12px 13px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(15, 139, 99, .12); }
.field-row { display: grid; gap: 12px; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.action-stack { display: grid; gap: 9px; }
.action-stack button, .login-card button { border: 0; border-radius: 15px; padding: 13px 16px; background: var(--green); color: #fffaf1; font-weight: 950; text-align: left; }
.action-stack button.secondary { background: #efe3d0; color: var(--ink); }
.action-stack button.print-button { background: var(--terracotta); color: #fffaf1; }
.message { min-height: 22px; margin: 0; color: var(--green); font-weight: 800; }
.message.error { color: var(--danger); }

.document-area { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(460px, 1.18fr); gap: 18px; }
.editor-panel, .preview-panel, .history-panel { padding: 18px; }
.section-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title span { color: var(--muted); font-size: 12px; font-weight: 800; }
.json-editor { min-height: 720px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; line-height: 1.45; }
iframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.history-panel { margin-top: 18px; }
.applications { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.application { display: grid; gap: 6px; border: 1px solid var(--line); border-radius: 16px; background: #fffaf1; color: var(--muted); text-align: left; padding: 14px; }
.application strong { color: var(--ink); }
.application span { font-size: 12px; }

.login-body { min-height: 100vh; background: #efe0cc; overflow-x: hidden; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .62fr); }
.login-story { min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 34px; background: radial-gradient(circle at 75% 18%, rgba(140, 80, 45, .42), transparent 28%), linear-gradient(135deg, #17201a, #0d2d24 54%, #0a1512); color: #fffaf1; }
.login-nav { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.login-brand { color: #fffaf1; }
.login-brand .brand-mark { background: #fffaf1; color: #17201a; }
.login-brand small { color: #cfe0d4; }
.login-copy { max-width: 760px; }
.login-copy h1 { font-size: clamp(52px, 8vw, 112px); }
.login-copy p:not(.eyebrow) { max-width: 620px; color: #d9e4d9; font-size: 20px; line-height: 1.55; }
.login-proof { display: flex; flex-wrap: wrap; gap: 10px; }
.login-proof span { border: 1px solid rgba(255,250,241,.18); border-radius: 999px; color: #eaf7ee; padding: 9px 12px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.login-card { align-self: center; width: min(440px, calc(100% - 36px)); margin: 0 auto; padding: 28px; }
.login-card h2 { margin-bottom: 10px; font-size: 30px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-card form { display: grid; gap: 16px; margin-top: 22px; }
.turnstile-box { min-height: 70px; }

@media (max-width: 1060px) {
  .workspace-grid, .document-area, .command-center, .login-shell { grid-template-columns: 1fr; }
  .tool-panel { position: static; }
  .login-story { min-height: auto; gap: 90px; }
  .login-card { margin: 24px auto; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 20px, 1480px); padding-top: 10px; }
  .topbar { position: static; align-items: flex-start; }
  .topbar, .topbar-actions, .login-nav { flex-direction: column; }
  .topbar-actions { align-items: stretch; width: 100%; }
  .session-pill, .ghost-link, .language-button { width: 100%; justify-content: center; text-align: center; }
  .command-center { padding: 24px; }
  .field-row.two, .field-row.three { grid-template-columns: 1fr; }
  .json-editor, iframe { min-height: 460px; height: 460px; }
  .login-story { padding: 22px; }
  .login-card { width: min(100% - 24px, 440px); }
}
