:root{
  --bg:#0b0c10;
  --panel:#11131a;
  --text:#e9ecf1;
  --muted:#a8b0bf;
  --border:#232635;
  --accent:#6ea8fe;
  --good:#41d19a;
  --warn:#f5c451;
  --bad:#ff6b6b;
  --shadow: 0 10px 30px rgba(0,0,0,.25);
  --radius:14px;
  --gap:14px;
}

html[data-theme="light"]{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --text:#101322;
  --muted:#4f5b6b;
  --border:#d7deea;
  --accent:#2f6fed;
  --good:#0f9d71;
  --warn:#c08700;
  --bad:#d93025;
  --shadow: 0 10px 30px rgba(16,19,34,.12);
}


*{ box-sizing:border-box; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background: radial-gradient(1200px 600px at 20% 0%, #151a2a 0%, var(--bg) 55%),
              radial-gradient(900px 500px at 85% 15%, #1b243d 0%, var(--bg) 55%);
  min-height:100vh;
}

header{
  padding:22px 18px 10px;
  max-width:1200px;
  margin:0 auto;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
}

header h1{
  margin:0;
  font-size:18px;
  letter-spacing:.2px;
  font-weight:700;
}

header .sub{
  margin:6px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.4;
}

.wrap{
  max-width:1200px;
  margin:0 auto;
  padding:10px 18px 28px;
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  grid-template-areas:
    "editor details"
    "notes keywords";
gap:var(--gap);
}

@media (max-width: 980px){
  .wrap{ grid-template-columns: 1fr; grid-template-areas: "editor" "details" "keywords" "notes"; }
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.card .hd{
  padding:14px 14px 10px;
  border-bottom:1px solid rgba(255,255,255,.05);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.card .hd .title{
  font-weight:700;
  font-size:13px;
  color:#dfe5f2;
  letter-spacing:.2px;
}

.card .bd{
  padding:14px;
}

textarea{
  width:100%;
  min-height:420px;
  resize:vertical;
  padding:14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.08);
  background: rgba(10,12,18,.55);
  color:var(--text);
  outline:none;
  line-height:1.55;
  font-size:15px;
}

textarea:focus{
  border-color: rgba(110,168,254,.5);
  box-shadow: 0 0 0 3px rgba(110,168,254,.18);
}

.btnrow{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  justify-content:flex-end;
}

.editor-card .btnrow{
  margin-top: 10px;
}

button{
  appearance:none;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
  color:var(--text);
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
  font-size:13px;
}

button:hover{ background: rgba(255,255,255,.08); }
button:active{ transform: translateY(1px); }

.primary{
  border-color: rgba(110,168,254,.4);
  background: rgba(110,168,254,.12);
}

.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap:10px;
}

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

.metric{
  padding:12px;
  border-radius:12px;
  background: rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.06);
}

.metric .k{
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}

.metric .v{
  font-size:24px;
  font-weight:800;
  letter-spacing:.2px;
}

.metric .s{
  margin-top:6px;
  font-size:12px;
  color:var(--muted);
}

.metric.full{
  grid-column: 1 / -1;
}

.row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.right{
  text-align:right;
}

.readability-feature .pill{
  margin-top: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  padding: 4px 10px;
  font-weight: 600;
}

.v.small{
  font-size:20px;
}

.controls{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
  margin-top:10px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.06);
}

.control{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--muted);
  font-size:13px;
}

.control input[type="range"]{ width:160px; }

.control label{
  display:flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
  user-select:none;
}

.control input[type="checkbox"]{
  width:16px;
  height:16px;
  accent-color: var(--accent);
}

table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}

th, td{
  padding:10px 8px;
  border-bottom:1px solid rgba(255,255,255,.06);
  text-align:left;
  vertical-align:top;
}

th{
  color:#dfe5f2;
  font-weight:700;
  font-size:12px;
  letter-spacing:.2px;
}

td{ color:var(--text); }
.muted{ color:var(--muted); }

.pill{
  display:inline-flex;
  align-items:center;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
}

.pill.good{ border-color: rgba(65,209,154,.35); background: rgba(65,209,154,.10); color:#bff5e3; }
.pill.warn{ border-color: rgba(245,196,81,.35); background: rgba(245,196,81,.10); color:#ffe8b3; }
.pill.bad{ border-color: rgba(255,107,107,.35); background: rgba(255,107,107,.10); color:#ffd0d0; }

.footer-note{
  max-width:1200px;
  margin:0 auto;
  padding:0 18px 26px;
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

}

.bd.tight{ padding-top:6px; }
.bd.note{
  color:var(--muted);
  font-size:13px;
  line-height:1.55;
}
.spacer{ margin-top:10px; }


html[data-theme="light"] body{
  background: radial-gradient(1200px 600px at 20% 0%, #dfe7ff 0%, var(--bg) 55%),
              radial-gradient(900px 500px at 85% 15%, #e9ddff 0%, var(--bg) 55%);
}





html[data-theme="light"] .card{
  background: linear-gradient(180deg, rgba(16,19,34,.02), rgba(16,19,34,.01));
}
html[data-theme="light"] textarea{
  background: rgba(255,255,255,.75);
  border-color: rgba(16,19,34,.14);
}
html[data-theme="light"] textarea:focus{
  border-color: rgba(47,111,237,.55);
  box-shadow: 0 0 0 3px rgba(47,111,237,.18);
}
html[data-theme="light"] .metric{
  background: rgba(16,19,34,.03);
  border-color: rgba(16,19,34,.08);
}

html[data-theme="light"] th{
  color: rgba(16,19,34,.86);
  border-bottom-color: rgba(16,19,34,.10);
}


/* Theme switch */
.theme-switch{
  flex-shrink:0;
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05);
}

html[data-theme="light"] .theme-switch{
  flex-shrink:0;
  border-color: rgba(16,19,34,.14);
  background: rgba(16,19,34,.03);
}

.theme-label{
  font-size:12px;
  color: var(--muted);
  user-select:none;
}

.switch{
  position:relative;
  display:inline-block;
  width:46px;
  height:26px;
}

.switch input{
  opacity:0;
  width:0;
  height:0;
}

.slider{
  position:absolute;
  cursor:pointer;
  inset:0;
  border-radius:999px;
  background: rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.18);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.slider:before{
  position:absolute;
  content:"";
  height:20px;
  width:20px;
  left:3px;
  top:50%;
  transform: translateY(-50%);
  border-radius:999px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 6px 14px rgba(0,0,0,.25);
  transition: transform .2s ease, background .2s ease;
}

.switch input:focus-visible + .slider{
  box-shadow: 0 0 0 3px rgba(110,168,254,.22);
  border-color: rgba(110,168,254,.45);
}

.switch input:checked + .slider{
  background: rgba(110,168,254,.18);
  border-color: rgba(110,168,254,.45);
}

.switch input:checked + .slider:before{
  transform: translate(20px, -50%);
  background: rgba(255,255,255,.95);
}

html[data-theme="light"] .slider{
  background: rgba(16,19,34,.08);
  border-color: rgba(16,19,34,.14);
}

html[data-theme="light"] .switch input:focus-visible + .slider{
  box-shadow: 0 0 0 3px rgba(47,111,237,.18);
  border-color: rgba(47,111,237,.45);
}

html[data-theme="light"] .switch input:checked + .slider{
  background: rgba(47,111,237,.16);
  border-color: rgba(47,111,237,.45);
}

html[data-theme="light"] .slider:before{
  background: rgba(255,255,255,.98);
  box-shadow: 0 6px 14px rgba(16,19,34,.16);
}


/* Header controls layout (theme toggle on its own line) */
.header-controls{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:10px;
}

.header-controls-top{
  display:flex;
  justify-content:flex-end;
}

.header-actions{
  justify-content:flex-end;
}


/* Grid areas for consistent alignment */
.editor-card{ grid-area: editor; }
.details-card{ grid-area: details; }
.keywords{ grid-area: keywords; }
.notes{ grid-area: notes; }


/* Light mode heading readability improvements */
html[data-theme="light"] header h1{
  color: var(--text);
}

html[data-theme="light"] .card .hd{
  background: rgba(255,255,255,.7);
  border-bottom: 1px solid rgba(16,19,34,.10);
}

html[data-theme="light"] .card .hd .title{
  color: #101322;
}

html[data-theme="light"] .card .hd .pill{
  color: rgba(16,19,34,.70);
  border-color: rgba(16,19,34,.14);
  background: rgba(16,19,34,.04);
}

html[data-theme="light"] .readability-feature .pill.muted{
  color: rgba(16,19,34,.72);
  border-color: rgba(16,19,34,.16);
  background: rgba(16,19,34,.05);
}

html[data-theme="light"] .readability-feature .pill.good{
  color: #0f6b4a;
  border-color: rgba(15,107,74,.22);
  background: rgba(34,197,94,.14);
}

html[data-theme="light"] .readability-feature .pill.warn{
  color: #8a5a00;
  border-color: rgba(138,90,0,.22);
  background: rgba(245,158,11,.18);
}

html[data-theme="light"] .readability-feature .pill.bad{
  color: #9f1239;
  border-color: rgba(159,18,57,.20);
  background: rgba(244,63,94,.14);
}


html[data-theme="light"] header .sub{
  color: rgba(16,19,34,.70);
}
