:root {
  --muted-color: #667687;
  --panel-bg: #fff;
  --soft-bg: #f5f8f9;
}

[data-theme="dark"] {
  --bg-color: #07111f;
  --text-color: #e7edf4;
  --header-bg: rgba(8, 19, 33, .9);
  --input-bg: #0e1b2c;
  --input-border: #22354b;
  --hover-bg: #17283c;
  --dropdown-bg: #0e1b2c;
  --dropdown-border: #263a50;
  --divider-color: #203248;
  --muted-color: #8fa1b4;
  --panel-bg: #0b1828;
  --soft-bg: #101f31;
}

html { background: var(--bg-color); }
body {
  letter-spacing: -.01em;
  background: radial-gradient(circle at 72% -12%, rgba(16,185,129,.12), transparent 30rem), var(--bg-color);
}

.app-header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid color-mix(in srgb, var(--divider-color) 82%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.header-shell { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; flex: 0 0 auto; }
.brand-mark {
  width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px;
  color: #04110d; background: linear-gradient(145deg,#5ee4b7,#10b981);
  box-shadow: 0 8px 24px rgba(16,185,129,.24); font-weight: 800; font-size: 1.05rem;
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: .98rem; letter-spacing: -.02em; }
.brand-copy small { margin-top: .3rem; color: var(--muted-color); font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; }
.menu-button { color: var(--muted-color); border-radius: 8px; font-weight: 600; }
.menu-button:hover,.menu-button[aria-expanded="true"] { color: var(--text-color); }
.dropdown { border-radius: 12px; padding: .45rem; min-width: 190px; }
.dropdown-item { border-radius: 7px; }

.workspace-intro { padding: 3.25rem 1rem 2.35rem; text-align: center; background: transparent; position: relative; overflow: hidden; }
.workspace-intro::before {
  content:""; position:absolute; width:34rem; height:14rem; border-radius:50%;
  background:rgba(16,185,129,.11); filter:blur(70px); top:-11rem; left:50%; transform:translateX(-50%); pointer-events:none;
}
.workspace-intro h1 { font-size:clamp(2rem,4vw,3.35rem); line-height:1.05; letter-spacing:-.045em; color:var(--text-color); position:relative; }
.workspace-intro p { color:var(--muted-color); font-size:1.05rem; margin:.85rem auto 0; }
.eyebrow,.section-kicker { display:inline-block; color:#34d399; font-size:.66rem; font-weight:750; letter-spacing:.14em; }
.eyebrow { margin-bottom:.85rem; }

.workspace { width:min(100% - 2rem,1280px); padding:0 0 2.25rem; align-items:stretch; }
.editor-column,#stats-panel {
  background:var(--panel-bg)!important; border:1px solid var(--divider-color); border-radius:16px;
  box-shadow:0 18px 55px rgba(2,10,20,.14);
}
.editor-column { padding:1.15rem; min-width:0; }
.editor-heading { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.1rem .15rem; }
.editor-heading h2,#stats-panel h3 { margin-top:.18rem; font-size:1.08rem; font-weight:700; letter-spacing:-.025em; }
.autosave-pill { display:inline-flex; align-items:center; gap:.45rem; color:var(--muted-color); font-size:.72rem; white-space:nowrap; }
.autosave-pill span { width:7px; height:7px; border-radius:50%; background:#34d399; box-shadow:0 0 0 4px rgba(52,211,153,.1); }

#text-edit { min-height:390px; border-radius:12px; padding:1.15rem; line-height:1.7; box-shadow:inset 0 1px 0 rgba(255,255,255,.03); }
#text-edit::placeholder,input::placeholder { color:color-mix(in srgb,var(--muted-color) 74%,transparent); }
.pattern-row { background:var(--soft-bg); border:1px solid var(--divider-color); padding:.55rem; border-radius:11px; }
.pattern-row input[type="text"] { border:0; background:transparent; padding-left:.45rem; }

#action-bar { margin:0 -.15rem -.25rem; padding:.75rem .15rem .25rem; background:var(--panel-bg)!important; }
#action-bar button {
  min-height:42px; border-radius:10px; border:1px solid var(--divider-color); background:var(--soft-bg); color:var(--text-color);
  font-size:.88rem; font-weight:650; box-shadow:none; transition:transform 160ms ease,border-color 160ms ease,background 160ms ease;
}
#action-bar button:hover { transform:translateY(-1px); border-color:color-mix(in srgb,var(--accent-color) 50%,var(--divider-color)); background:var(--hover-bg); }
#action-bar button:first-child { background:linear-gradient(135deg,#12b981,#0b8f70); border-color:transparent; color:#fff; box-shadow:0 9px 22px rgba(16,185,129,.18); }
#action-bar button:first-child:hover { background:linear-gradient(135deg,#19c68c,#0c9877); }
#action-bar svg { opacity:.88; }

#stats-panel { width:300px; padding:1.2rem; }
#stats-panel > .flex:first-child { border-bottom:1px solid var(--divider-color); padding-bottom:1rem; }
#stats-toggle { width:29px; height:29px; display:grid; place-items:center; border:1px solid var(--divider-color); border-radius:8px; writing-mode:initial; }
#stats-content .grid > div,#frequent-words,#char-frequency { background:var(--soft-bg)!important; border:1px solid var(--divider-color); box-shadow:none; border-radius:10px; }
#stats-content .grid > div { padding:.75rem; }
#stats-content .text-xl { margin-top:.15rem; font-size:1.35rem; }
#stats-content h4 { font-size:.8rem; color:var(--muted-color); text-transform:uppercase; letter-spacing:.07em; }
footer { border-color:var(--divider-color); color:var(--muted-color); background:transparent; }
.dialog { border-radius:16px!important; border-color:var(--divider-color); }
.qr-code { width:176px; min-height:176px; margin:.75rem auto 0; padding:8px; display:grid; place-items:center; border-radius:12px; background:#fff; }
.qr-code canvas,.qr-code img { display:block; width:160px!important; height:160px!important; }

@media (max-width:860px) {
  .header-shell { align-items:flex-start; flex-direction:column; gap:.65rem; padding-top:.75rem; padding-bottom:.55rem; }
  .header-shell nav { width:100%; overflow-x:auto; padding-bottom:.2rem; }
  .workspace-intro { padding-top:2.5rem; }
  .workspace { flex-direction:column; }
  #stats-panel { width:100%; }
  #stats-panel.collapsed { transform:none; }
}
@media (max-width:560px) {
  .brand-copy small,.autosave-pill { display:none; }
  .workspace { width:min(100% - 1rem,1280px); }
  .editor-column { padding:.85rem; }
  .pattern-row { align-items:stretch; flex-direction:column; gap:.5rem; }
  #action-bar button { flex:1 1 calc(50% - .5rem); min-width:0; justify-content:center; }
  #text-edit { min-height:340px; }
}
