/* ===============================
   ShopySquares Article Generator UI (v3-ready)
   - Updated for: taxonomy-driven topics + length profiles (short/medium/long)
   - Keeps your light/dark/neon themes
   - Adds: .chip + improved select/option behavior + nicer output blocks
   =============================== */

:root{
  --pageBg:#f0f2f5;
  --surface:#ffffff;
  --surface2:#f7f8fa;
  --stroke:#c7d0df;
  --stroke2:#e3e8f2;
  --shadow: 0 12px 32px rgba(0,0,0,.10);

  --txt:#111827;
  --muted:#6b7280;

  --accent:#1877F2;
  --accent2:#0f5ed1;

  --green:#2bb24c;
  --green2:#1f8f3b;

  --r:16px;
  --r2:14px;

  /* NEW: helpful tones */
  --warn:#b45309;
  --warnBg: rgba(245,158,11,.14);
  --warnBr: rgba(245,158,11,.25);

  --danger:#b42318;
  --dangerBg: rgba(180,35,24,.10);
  --dangerBr: rgba(180,35,24,.22);
}

body[data-theme="dark"]{
  --pageBg:#0f1220;
  --surface:rgba(255,255,255,.07);
  --surface2:rgba(255,255,255,.05);
  --stroke:rgba(255,255,255,.14);
  --stroke2:rgba(255,255,255,.10);
  --shadow: 0 22px 55px rgba(0,0,0,.42);

  --txt:#eef2ff;
  --muted:#aab2d6;

  --accent:#1877F2;
  --accent2:#0f5ed1;

  --warn:#fbbf24;
  --warnBg: rgba(251,191,36,.12);
  --warnBr: rgba(251,191,36,.22);

  --danger:#ff7b72;
  --dangerBg: rgba(255,123,114,.12);
  --dangerBr: rgba(255,123,114,.22);

  background:
    radial-gradient(1200px 700px at 20% 10%, rgba(24,119,242,.14), transparent 60%),
    linear-gradient(180deg, #0b0e18, #0f1220);
}

body[data-theme="neon"]{
  --pageBg:#110623;
  --surface:rgba(20,14,44,.78);
  --surface2:rgba(16,10,36,.72);
  --stroke:rgba(120,90,220,.32);
  --stroke2:rgba(120,90,220,.20);
  --shadow: 0 22px 60px rgba(0,0,0,.42);

  --txt:#e9e6ff;
  --muted:#b8b2e6;

  /* Neon accent stays green */
  --accent:#0f6f3a;
  --accent2:#0b4f2a;
  --yellow:#ffd54a;

  --warn:#ffd54a;
  --warnBg: rgba(255,213,74,.10);
  --warnBr: rgba(255,213,74,.22);

  --danger:#ff6b6b;
  --dangerBg: rgba(255,107,107,.10);
  --dangerBr: rgba(255,107,107,.22);

  background:
    radial-gradient(1100px 700px at 15% 12%, rgba(15,111,58,.10), transparent 60%),
    radial-gradient(900px 600px at 85% 10%, rgba(168,120,255,.10), transparent 55%),
    radial-gradient(900px 650px at 40% 92%, rgba(120,90,220,.10), transparent 55%),
    linear-gradient(180deg, #110623, #070313);
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial;
  color:var(--txt);
  background: linear-gradient(180deg, #ffffff 0%, var(--pageBg) 55%, var(--pageBg) 100%);
  min-height:100vh;
  font-weight:400;
}

body[data-theme="dark"]{ color-scheme: dark; }
body[data-theme="neon"]{ color-scheme: dark; }

/* Selects + options in dark/neon */
body[data-theme="dark"] select,
body[data-theme="neon"] select{
  background: var(--surface2) !important;
  color: var(--txt) !important;
  border-color: var(--stroke) !important;
}
body[data-theme="dark"] select option,
body[data-theme="neon"] select option{
  background: #0f1220 !important;
  color: #eef2ff !important;
}
body[data-theme="dark"] select option[disabled],
body[data-theme="neon"] select option[disabled]{
  color: rgba(238,242,255,.55) !important;
}

/* Layout */
.app{
  max-width:1440px;
  margin:0 auto;
  padding:20px 18px 38px;
  display:grid;
  grid-template-columns: 340px 1fr;
  gap:16px;
}

.side{
  position:sticky;
  top:16px;
  align-self:start;
  border:1px solid var(--stroke);
  border-radius:var(--r);
  background:var(--surface);
  box-shadow:var(--shadow);
  overflow:hidden;
}

.sideTop{
  padding:16px;
  border-bottom:1px solid var(--stroke2);
  display:flex;
  gap:12px;
  align-items:center;
}

.brandLink{
  display:flex;
  gap:12px;
  align-items:center;
  text-decoration:none;
  color:inherit;
}

.logo{
  width:52px;height:52px;border-radius:14px;
  object-fit:cover;
  box-shadow:0 0 0 1px rgba(0,0,0,.06);
  flex:0 0 auto;
}
body[data-theme="dark"] .logo,
body[data-theme="neon"] .logo{
  box-shadow:0 0 0 1px rgba(255,255,255,.10);
}

.brandText{display:flex;flex-direction:column;gap:4px;line-height:1.1}
.brandText .name{font-size:14px;letter-spacing:.15px}
.brandText .sub{font-size:12px;color:var(--muted)}

/* NEW: subtle chips for v3 metadata (length / template / domain if you print them) */
.chipRow{display:flex; gap:8px; flex-wrap:wrap; margin-top:10px}
.chip{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:var(--surface2);
  color:var(--muted);
  white-space:nowrap;
}
.chip strong{color:var(--txt); font-weight:700}
.chip.ok{
  border-color: rgba(43,178,76,.25);
  background: rgba(43,178,76,.10);
  color: var(--green2);
}
.chip.warn{
  border-color: var(--warnBr);
  background: var(--warnBg);
  color: var(--warn);
}
.chip.bad{
  border-color: var(--dangerBr);
  background: var(--dangerBg);
  color: var(--danger);
}

.sideNav{
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.navItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:14px 14px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:var(--surface2);
  text-decoration:none;
  color:var(--txt);
  transition:transform .10s ease, border-color .10s ease, background .10s ease;
}
.navItem:hover{
  transform:translateY(-1px);
  border-color:rgba(24,119,242,.35);
  background:#eef5ff;
}
body[data-theme="dark"] .navItem:hover{ background:rgba(24,119,242,.10); }
body[data-theme="neon"] .navItem:hover{
  background:rgba(15,111,58,.10);
  border-color:rgba(15,111,58,.28);
}

.tag{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(24,119,242,.25);
  color:var(--accent);
  background:var(--surface);
  white-space:nowrap;
}
body[data-theme="neon"] .tag{
  border-color: rgba(15,111,58,.35);
  color: var(--accent);
}

/* Main */
.main{min-width:0; display:flex; flex-direction:column; gap:16px;}

.headerCard{
  border:1px solid var(--stroke);
  border-radius:var(--r);
  background:var(--surface);
  box-shadow:var(--shadow);
  padding:16px 16px;
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
}

.headerTitle{display:flex;flex-direction:column;gap:6px;flex:1;padding:0 4px;}
.headerTitle h1{
  margin:0;
  font-size:20px;
  font-weight:800;
  letter-spacing:.2px;
  color:var(--txt);
}
body[data-theme="neon"] .headerTitle h1{ color: var(--yellow); }

.headerTitle p{
  margin:0;
  font-size:13px;
  color:var(--muted);
  line-height:1.55;
}

.headerRight{display:flex; align-items:center; gap:12px; flex-wrap:wrap;}

.pill{
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:var(--surface2);
  color:var(--txt);
  font-size:13px;
  white-space:nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing:.4px;
}
select.pill{cursor:pointer; padding-right:10px;}

/* Cards */
.card{
  border:1px solid var(--stroke);
  border-radius:var(--r);
  background:var(--surface);
  box-shadow:var(--shadow);
  padding:18px;
  min-width:0;
}

.cardHead{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:12px;
  margin-bottom:14px;
}
.cardHead .title{font-size:14px; letter-spacing:.2px;}
.cardHead .meta{font-size:12px;color:var(--muted);text-align:right;min-width:240px}

/* Inputs */
label{font-size:12px;color:var(--txt);display:block;margin-bottom:6px;}

select,input,textarea{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid var(--stroke);
  background:var(--surface);
  color:var(--txt);
  outline:none;
}

/* NEW: make selects look “length/taxonomy friendly” */
select{
  appearance:auto;
  line-height:1.15;
}
select:disabled,
input:disabled,
textarea:disabled{
  opacity:.75;
  cursor:not-allowed;
}

textarea{
  min-height:170px;
  resize:vertical;
  font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height:1.38;
  background:var(--surface2);
}

select:focus,input:focus,textarea:focus{
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Grids */
.grid{display:grid; grid-template-columns: 1.1fr 1fr 1fr .8fr; gap:12px;}
.grid2{display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-top:12px;}
.grid3{display:grid; grid-template-columns: 1fr 1fr 1fr; gap:12px; margin-top:12px;}

@media (max-width:1160px){
  .app{grid-template-columns:1fr}
  .side{position:relative;top:0}
}
@media (max-width:960px){
  .grid{grid-template-columns:1fr 1fr}
  .grid2{grid-template-columns:1fr}
  .grid3{grid-template-columns:1fr}
  .headerCard{flex-direction:column; align-items:stretch}
  .headerRight{justify-content:flex-start}
}

/* Buttons */
.btns{display:flex; gap:10px; flex-wrap:wrap; margin-top:12px;}
button{
  cursor:pointer;
  border:1px solid var(--stroke);
  background:var(--surface2);
  color:var(--txt);
  padding:11px 14px;
  border-radius:14px;
  transition:transform .10s ease, border-color .10s ease, background .10s ease;
}
button:hover{
  transform: translateY(-1px);
  border-color: rgba(24,119,242,.35);
  background:#eef5ff;
}
body[data-theme="dark"] button:hover{ background:rgba(24,119,242,.10); }
body[data-theme="neon"] button:hover{
  background:rgba(15,111,58,.10);
  border-color:rgba(15,111,58,.30);
}
button:disabled{opacity:.55;cursor:not-allowed;transform:none}

button.primary{
  background: var(--accent);
  border-color: var(--accent);
  color:#fff;
}
button.primary:hover{
  background: var(--accent2);
  border-color: var(--accent2);
}

/* Helper rows */
.hintRow{display:flex; justify-content:space-between; gap:12px; margin-top:10px; flex-wrap:wrap;}
.hint{font-size:12px;color:var(--muted)}
/* Show error badge only when it has text */
.err{ display:none; }
.err:not(:empty){
  display:inline-block;
  color: var(--danger);
  background: var(--dangerBg);
  border: 1px solid var(--dangerBr);
  padding: 8px 10px;
  border-radius: 12px;
}

/* Progress */
.progressWrap{display:none;margin-top:12px}
.progressTop{display:flex;justify-content:space-between;gap:10px;align-items:center}
.progressText{font-size:12px;color:var(--muted)}
.countdown{
  font-size:12px;
  color: var(--green2);
  background: rgba(43,178,76,.12);
  border: 1px solid rgba(43,178,76,.25);
  padding: 6px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .4px;
  white-space: nowrap;
}
.bar{
  height:10px;
  border-radius:999px;
  background: rgba(0,0,0,.06);
  border:1px solid var(--stroke);
  overflow:hidden;
  margin-top:8px;
}
body[data-theme="dark"] .bar{ background: rgba(255,255,255,.07); }
body[data-theme="neon"] .bar{ background: rgba(255,255,255,.06); border-color: rgba(120,90,220,.25); }
.bar > span{
  display:block;
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--green), var(--green2));
  transition: width .25s linear;
}

/* Article render area (IMPORTANT for v3 HTML classes) */
.tw-article{
  background:var(--surface2);
  border:1px solid var(--stroke);
  border-radius:var(--r2);
  padding:16px;
  overflow-wrap:anywhere;
}

/* Make the generated HTML look good */
.tw-article .tw-h1,
.tw-article .tw-h2,
.tw-article .tw-h3,
.tw-article .tw-p,
.tw-article .tw-meta{font-weight:400}

.tw-article .tw-h1{font-size:28px;margin:0 0 10px;color:var(--txt)}
.tw-article .tw-h2{font-size:20px;margin:18px 0 8px;color:var(--txt)}
.tw-article .tw-h3{font-size:16px;margin:14px 0 6px;color:var(--txt)}
.tw-article .tw-p{font-size:15px;line-height:1.75;margin:10px 0;color:var(--txt)}
.tw-article .tw-ul{margin:10px 0 14px 18px}
.tw-article .tw-li{margin:6px 0}

.tw-article .tw-meta{
  font-size:13px;
  color:var(--muted);
  margin-top:12px;
  padding-top:10px;
  border-top:1px dashed rgba(0,0,0,.18);
}
body[data-theme="dark"] .tw-article .tw-meta{ border-top:1px dashed rgba(255,255,255,.18); }
body[data-theme="neon"] .tw-article .tw-meta{ border-top:1px dashed rgba(168,120,255,.30); }

.tw-article a{color:var(--accent);text-decoration:underline}

/* Output tabs */
.tabs{
  display:inline-flex;
  gap:6px;
  padding:6px;
  border-radius:999px;
  border:1px solid var(--stroke);
  background:var(--surface2);
  margin-top:8px;
}
.tab{
  border:1px solid transparent;
  background:transparent;
  border-radius:999px;
  padding:8px 12px;
  color:var(--muted);
  cursor:pointer;
}
.tab.active{
  color:#fff;
  border-color: var(--accent);
  background: var(--accent);
}

.outBlock{margin-top:12px}
.outHidden{display:none}

/* NEW: textarea outputs look cleaner */
textarea#outPlain, textarea#outMd, textarea#outHtml{
  min-height:240px;
  background: var(--surface);
  border-color: var(--stroke2);
}

/* Footer */
.footerCard{
  border:1px solid var(--stroke);
  border-radius:var(--r);
  background:var(--surface);
  box-shadow:var(--shadow);
  padding:16px;
  color:var(--muted);
  font-size:12px;
  line-height:1.65;
}
.footerCard a{color:var(--accent);text-decoration:underline}