:root{
  --ink:#000000;
  --text:#40444f;
  --deep:#222222;
  --blue:#0692e5;
  --blue-dark:#0478bc;
  --green:#8cc938;
  --green-dark:#70a22c;
  --purple:#8b65dc;
  --orange:#f48515;
  --mist:#a1b7bf;
  --line:#bec9ce;
  --panel:#adc1c9;
  --soft:#e3e3e3;
  --page:#f0f0f0;
  --white:#ffffff;
  --radius-xs:3px;
  --radius-sm:10px;
  --radius-md:16px;
  --radius-lg:20px;
  --radius-xl:28px;
  --radius-pill:50px;
  --shadow-ink:inset 0 -2px 0 rgb(51,54,63);
  --shadow-green:inset 0 -2px 0 rgb(112,162,44);
  --shadow-panel:inset 0 -3px 0 rgb(173,193,201);
}

*{box-sizing:border-box}
html{background:var(--page)}
body{
  margin:0;
  min-width:320px;
  background:var(--page);
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-size:15px;
  line-height:1.55;
}

a{color:inherit;text-decoration:none}

header,footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:24px;
  padding:18px clamp(18px,4vw,56px);
  background:var(--white);
  border-bottom:1px solid var(--line);
}

header{
  position:sticky;
  top:0;
  z-index:10;
  box-shadow:var(--shadow-panel);
}

header>a{
  display:inline-flex;
  align-items:center;
  min-height:44px;
  max-width:420px;
  padding:10px 18px;
  border-radius:var(--radius-pill);
  background:var(--deep);
  color:var(--white);
  font-weight:800;
  line-height:1.1;
  box-shadow:var(--shadow-ink);
}

nav{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:8px;
}

nav a,footer a,footer select{
  display:inline-flex;
  align-items:center;
  min-height:38px;
  padding:8px 13px;
  border:1px solid var(--line);
  border-radius:var(--radius-pill);
  background:var(--white);
  color:var(--text);
  font-weight:700;
}

nav a:hover,footer a:hover{border-color:var(--blue);color:var(--blue)}

main{
  width:min(1180px,100%);
  margin:0 auto;
  padding:34px clamp(16px,3vw,32px) 64px;
}

.hero{
  margin:0 0 18px;
  padding:34px clamp(22px,5vw,50px);
  border:1px solid var(--line);
  border-radius:var(--radius-xl);
  background:var(--panel);
  color:var(--deep);
  box-shadow:var(--shadow-panel);
}

.hero h1{
  margin:0;
  max-width:860px;
  color:var(--ink);
  font-size:44px;
  line-height:1.02;
  font-weight:900;
}

.hero p{
  max-width:840px;
  margin:16px 0 0;
  color:var(--text);
  font-size:17px;
}

.tool-card{
  width:100%;
  max-width:none;
  margin:18px 0 20px;
  padding:28px;
  border:1px solid var(--line);
  border-radius:var(--radius-xl);
  background:var(--white);
  box-shadow:var(--shadow-panel);
}

.tool-grid{
  display:grid;
  grid-template-columns:minmax(0,1.05fr) minmax(310px,.95fr);
  gap:24px;
  align-items:start;
}

.tool-pane,.preview-pane,.qr-preview{
  min-width:0;
}

label{
  display:block;
  margin:13px 0 7px;
  color:var(--deep);
  font-size:14px;
  font-weight:800;
}

textarea,input,select{
  width:100%;
  min-height:44px;
  padding:12px 14px;
  border:2px solid var(--line);
  border-radius:var(--radius-md);
  background:var(--white);
  color:var(--ink);
  font:inherit;
  outline:0;
  box-shadow:inset 0 -2px 0 var(--soft);
}

textarea{
  min-height:150px;
  resize:vertical;
}

textarea:focus,input:focus,select:focus{
  border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(6,146,229,.14), inset 0 -2px 0 var(--blue);
}

input[type=checkbox]{
  width:auto;
  min-height:0;
  box-shadow:none;
}

input[type=color]{
  height:48px;
  padding:5px;
}

input[type=range]{
  padding:0;
  border:0;
  box-shadow:none;
  accent-color:var(--blue);
}

.controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:18px 0 8px;
}

button{
  min-height:46px;
  max-width:100%;
  margin:0;
  padding:12px 18px;
  border:0;
  border-radius:var(--radius-pill);
  background:var(--blue);
  color:var(--white);
  font:inherit;
  font-weight:900;
  cursor:pointer;
  box-shadow:inset 0 -2px 0 var(--blue-dark);
}

.controls button:first-child,
#image-process,
#pdf-run,
#subtitle-run,
#regex-run,
#qr-generate,
#run-tool,
#contrast-swap{
  background:var(--green);
  color:var(--deep);
  box-shadow:var(--shadow-green);
}

button:hover{filter:saturate(1.08) brightness(.98)}
button:active{transform:translateY(1px)}
button:disabled{opacity:.5;cursor:not-allowed;filter:grayscale(.2)}

output,.result-panel,.match-output{
  display:block;
  width:100%;
  margin-top:12px;
  padding:16px;
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  background:#f7fbfc;
  color:var(--deep);
  white-space:pre-wrap;
  overflow:auto;
  box-shadow:inset 0 -2px 0 var(--soft);
}

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

.result-grid div{
  min-width:0;
  padding:16px;
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  background:#f7fbfc;
  box-shadow:inset 0 -2px 0 var(--soft);
}

.result-grid strong{
  display:block;
  color:var(--ink);
  font-size:24px;
  line-height:1.05;
  font-weight:900;
}

.result-grid span,.small-note{
  display:block;
  margin-top:4px;
  color:#5b6874;
  font-size:13px;
}

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

.flag-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:10px 0 14px;
}

.flag-row label{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:36px;
  margin:0;
  padding:7px 12px;
  border:1px solid var(--line);
  border-radius:var(--radius-pill);
  background:#f7fbfc;
  font-weight:800;
}

.regex-input{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto 84px;
  align-items:center;
  overflow:hidden;
  border:2px solid var(--line);
  border-radius:var(--radius-md);
  background:var(--white);
  box-shadow:inset 0 -2px 0 var(--soft);
}

.regex-input input{
  border:0;
  border-radius:0;
  box-shadow:none;
}

.regex-input span{padding:0 10px;color:#65727d;font-weight:900}
.match-output mark{background:#dff3bd;color:#263900;border-radius:var(--radius-xs);padding:1px 3px}
.cheat-sheet{margin-top:14px}
.cheat-sheet summary{cursor:pointer;font-weight:900;color:var(--blue)}

.qr-preview,.preview-pane{
  display:grid;
  place-items:center;
  align-content:start;
  gap:16px;
  min-height:100%;
  padding:20px;
  border:1px solid var(--line);
  border-radius:var(--radius-xl);
  background:#f7fbfc;
  box-shadow:inset 0 -3px 0 var(--soft);
}

#image-canvas,#qr-canvas{
  max-width:100%;
  height:auto;
  border:1px solid var(--line);
  border-radius:var(--radius-lg);
  background:var(--white);
}

.contrast-preview{
  margin:14px 0;
  padding:30px;
  border:1px solid var(--line);
  border-radius:var(--radius-xl);
  font-size:20px;
  font-weight:900;
  box-shadow:inset 0 -3px 0 var(--soft);
}

.palette-output{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px;
}

.swatch{
  width:128px;
  min-height:0;
  padding:0;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:var(--radius-md);
  background:var(--white);
  color:var(--text);
  box-shadow:inset 0 -2px 0 var(--soft);
}

.swatch b{display:block;height:62px}
.swatch span{display:block;padding:9px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}

.badge{
  margin:18px 0;
  padding:14px 18px;
  border:1px solid var(--line);
  border-radius:var(--radius-pill);
  background:#f7fbfc;
  color:var(--text);
  font-weight:800;
  box-shadow:inset 0 -2px 0 var(--soft);
}

main>section:not(.hero):not(.tool-card):not(.badge){
  margin:18px 0;
  padding:24px 28px;
  border:1px solid var(--line);
  border-radius:var(--radius-xl);
  background:var(--white);
  box-shadow:inset 0 -3px 0 var(--soft);
}

h2,h3{
  margin:0 0 10px;
  color:var(--ink);
  line-height:1.12;
}

p{margin:0 0 10px}

details{
  padding:12px 0;
  border-top:1px solid var(--soft);
}

details:first-of-type{border-top:0}
summary{cursor:pointer;color:var(--deep);font-weight:900}

.ad-slot{
  margin:32px 0;
  padding:22px;
  border:2px dashed var(--line);
  border-radius:var(--radius-xl);
  background:transparent;
  color:#697783;
  text-align:center;
  font-weight:800;
}

table{
  width:100%;
  border-collapse:collapse;
}

td,th{
  padding:9px 8px;
  border-top:1px solid var(--soft);
  text-align:left;
}

footer{
  border-top:1px solid var(--line);
  border-bottom:0;
  box-shadow:inset 0 3px 0 var(--soft);
}

footer select{
  width:auto;
  min-height:38px;
  padding-right:34px;
  box-shadow:none;
}

.category-image .hero,.category-pdf .hero{background:#d9e5e9}
.category-seo .hero{background:#dcebf7}
.category-public-source .hero{background:#eee8fb}
.category-design .hero{background:#e8f4dc}

@media(max-width:860px){
  header,footer{align-items:flex-start;flex-direction:column}
  nav{justify-content:flex-start}
  .hero h1{font-size:34px}
  .tool-grid,.two-col{grid-template-columns:1fr}
  .result-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:540px){
  main{padding:22px 12px 42px}
  header,footer{padding:14px}
  header>a{max-width:100%;border-radius:var(--radius-lg)}
  nav a,footer a,footer select{min-height:36px;padding:7px 10px}
  .hero,.tool-card,main>section:not(.hero):not(.tool-card):not(.badge){padding:20px;border-radius:var(--radius-lg)}
  .hero h1{font-size:28px}
  .hero p{font-size:15px}
  .result-grid{grid-template-columns:1fr}
  .controls{display:grid;grid-template-columns:1fr}
  button{width:100%}
  .regex-input{grid-template-columns:auto minmax(0,1fr) auto 62px}
}
