/* MaiWebTools — shared stylesheet */
:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1d2723;
  --muted: #5f6b66;
  --border: #e4e2da;
  --accent: #0e7a63;
  --accent-hover: #0a604e;
  --accent-soft: #e9f2ee;
  --ok: #0f9d58;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(29,39,35,.05), 0 4px 16px rgba(29,39,35,.05);
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2321;
    --text: #e7ebe8;
    --muted: #9caba4;
    --border: #303a36;
    --accent: #58c3a5;
    --accent-hover: #74d3b8;
    --accent-soft: #1c2f29;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}
.svg-i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.18em; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
img, canvas, svg, video { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.12rem; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand strong { color: var(--accent); font-weight: 800; }
.brand-mark { flex: none; border-radius: 8px; }
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  color: var(--muted); font-weight: 600; font-size: .92rem;
  padding: 7px 12px; border-radius: 8px; white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
@media (max-width: 760px) {
  /* Two-row header: brand on top, nav in a clean row beneath */
  .header-inner {
    flex-wrap: wrap; height: auto; padding: 10px 20px 8px; row-gap: 6px;
    justify-content: flex-start;
  }
  .brand { width: 100%; }
  .site-nav {
    /* First link's text aligns with the logo and page content (9px link padding cancels out) */
    width: calc(100% + 18px); margin: 0 -9px; padding: 0;
    gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { font-size: .88rem; padding: 6px 9px; }
}

/* Page scaffold */
main { min-height: 60vh; padding-bottom: 56px; }
.page-head { padding: 40px 0 8px; }
.page-head h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 0 0 8px; letter-spacing: -.02em; }
.page-head .tagline { color: var(--muted); font-size: 1.05rem; margin: 0; max-width: 62ch; }
.breadcrumbs { font-size: .82rem; color: var(--muted); padding-top: 20px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs .sep { margin: 0 6px; opacity: .6; }

/* Hero (home) */
.hero { padding: 58px 0 26px; max-width: 680px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); margin: 0 0 14px; letter-spacing: -.02em; line-height: 1.12; }
.hero p { color: var(--muted); font-size: 1.1rem; margin: 0; }
.hero-points { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 26px; padding: 0; margin: 22px 0 0; }
.hero-points li { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--text); }
.hero-points .svg-i { color: var(--accent); }

/* Tool cards grid */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 40px 0 16px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.01em; }
.section-head a { font-size: .9rem; font-weight: 600; white-space: nowrap; }
.grid-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.tool-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tool-card:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.tool-card .icon {
  width: 40px; height: 40px; border-radius: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.tool-card h3 { margin: 0 0 6px; font-size: 1rem; }
.tool-card p { margin: 0; font-size: .85rem; color: var(--muted); line-height: 1.5; }

/* Tool panel */
.tool-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin: 22px 0;
}
.tool-panel .hint { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 14px 0; }
.controls label { font-size: .88rem; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.controls .field { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; font-weight: 600; }

/* Form elements */
textarea, input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="date"], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px;
  width: 100%; max-width: 100%;
}
textarea { min-height: 170px; resize: vertical; line-height: 1.55; }
textarea.mono, .mono { font-family: var(--mono); font-size: .88rem; }
input[type="number"] { width: 96px; }
input[type="date"] { width: auto; color-scheme: light dark; }
select { width: auto; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .92rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 38px 20px; text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone strong { color: var(--text); display: block; font-size: 1.02rem; margin-bottom: 4px; }
.dropzone.drag strong { color: var(--accent); }
.dropzone .sub { font-size: .85rem; }

/* Results / stats */
.result { margin-top: 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; }
.stat {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; min-width: 96px;
}
.stat .num { font-size: 1.25rem; font-weight: 700; display: block; line-height: 1.2; }
.stat .lbl { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.good .num { color: var(--ok); }
.stat.warn .num { color: var(--warn); }
.stat.bad .num { color: var(--danger); }
.preview-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; margin-top: 14px; overflow: auto; text-align: center;
}
.preview-box img, .preview-box canvas { max-height: 420px; border-radius: 6px; }
.file-meta { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.notice { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin-top: 12px; }
.error-note { background: rgba(220,38,38,.08); color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin-top: 12px; }

/* Simple table */
.table-wrap { overflow-x: auto; margin-top: 14px; }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }

/* Diff output */
.diff-out { font-family: var(--mono); font-size: .85rem; line-height: 1.6; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.diff-add { background: rgba(15,157,88,.18); color: inherit; border-radius: 3px; }
.diff-del { background: rgba(220,38,38,.18); text-decoration: line-through; border-radius: 3px; }

/* Progress meter (char limits) */
.meter { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); transition: width .15s; }
.meter.warn > span { background: var(--warn); }
.meter.over > span { background: var(--danger); }

/* Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.swatch { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; width: 108px; cursor: pointer; background: var(--surface); padding: 0; font: inherit; }
.swatch .chip { height: 56px; }
.swatch .hex { font-family: var(--mono); font-size: .8rem; padding: 7px 0; display: block; text-align: center; }

/* Content sections */
.content-section { max-width: 760px; }
.content-section h2 { font-size: 1.3rem; margin: 34px 0 10px; letter-spacing: -.01em; }
.content-section h3 { font-size: 1.08rem; margin: 24px 0 8px; letter-spacing: -.01em; }
.content-section p { color: var(--text); margin: 0 0 14px; }
.content-section ol, .content-section ul { padding-left: 22px; margin: 0 0 14px; }
.content-section li { margin-bottom: 7px; }

/* Guides */
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: .74rem; font-weight: 700; color: var(--accent); margin: 0 0 6px; }
.guide-meta { color: var(--muted); font-size: .85rem; margin-top: 10px; }
.guide-body { font-size: 1.02rem; line-height: 1.7; }
.guide-body h2:first-child { margin-top: 8px; }
.guide-body .notice { margin: 18px 0; }
.guide-body .table-wrap { margin: 18px 0; }

/* FAQ */
.faq details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 18px; margin-bottom: 10px;
}
.faq summary { font-weight: 600; padding: 14px 0; cursor: pointer; list-style: none; position: relative; padding-right: 28px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--accent); font-size: 1.2rem; font-weight: 700; }
.faq details[open] summary::after { content: "–"; }
.faq details p { color: var(--muted); margin: 0 0 14px; }

/* Related */
.related { margin-top: 40px; }

/* Ad slots (reserved space, no CLS) */
.ad-slot {
  margin: 26px 0; min-height: 100px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 10px;
  color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
}

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 40px 0 24px; }
.footer-inner { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.footer-brand { font-size: 1.05rem; margin: 0 0 8px; }
.footer-brand strong { color: var(--accent); }
.footer-note { color: var(--muted); font-size: .86rem; margin: 0; max-width: 34ch; }
.footer-head { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }
.footer-col a { display: block; color: var(--text); font-size: .9rem; padding: 4px 0; }
.footer-legal { border-top: 1px solid var(--border); margin-top: 30px; padding-top: 18px; font-size: .82rem; color: var(--muted); }

/* Two-pane text tool layout */
.pane-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) {
  .pane-2 { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; gap: 20px; }
  .hero { padding: 44px 0 28px; }
}
.pane label.pane-label { display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }

/* Markdown preview */
.md-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; overflow-x: auto; min-height: 170px; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: .6em 0 .4em; line-height: 1.25; }
.md-preview pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.md-preview code { font-family: var(--mono); font-size: .86em; background: var(--surface); padding: .1em .35em; border-radius: 4px; }
.md-preview pre code { background: none; padding: 0; }
.md-preview blockquote { border-left: 3px solid var(--accent); margin: 0 0 1em; padding: .2em 0 .2em 14px; color: var(--muted); }
.md-preview table { border-collapse: collapse; }
.md-preview td, .md-preview th { border: 1px solid var(--border); padding: 6px 10px; }

/* Crop tool */
.crop-stage { position: relative; display: inline-block; max-width: 100%; touch-action: none; }
.crop-stage img { display: block; max-width: 100%; max-height: 460px; user-select: none; -webkit-user-drag: none; }
.crop-box { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0,0,0,.45); cursor: move; }
.crop-handle { position: absolute; width: 14px; height: 14px; background: var(--accent); border: 2px solid #fff; border-radius: 50%; right: -8px; bottom: -8px; cursor: nwse-resize; }

/* Dark mode: readable text on the light accent */
@media (prefers-color-scheme: dark) {
  .btn-primary { color: #10201b; }
  .btn-primary:hover { color: #10201b; }
}

/* Report link under tool panel */
.tool-meta { display: flex; justify-content: flex-end; margin: -12px 0 0; }
.report-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 6px 4px; cursor: pointer;
  font: inherit; font-size: .82rem; color: var(--muted);
}
.report-link:hover { color: var(--danger); }

/* Modal dialog (report form) */
dialog.mwt-dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 22px; width: min(440px, calc(100vw - 40px));
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog.mwt-dialog::backdrop { background: rgba(10, 14, 12, .55); }
.mwt-dialog h2 { margin: 0 0 4px; font-size: 1.15rem; }
.mwt-dialog .hint { margin: 0 0 14px; }
.dialog-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 1.3rem; line-height: 1; padding: 4px 8px;
}
.dialog-close:hover { color: var(--text); }

/* Forms (contact + report) */
.form-grid { display: grid; gap: 14px; }
.form-grid label { font-weight: 600; font-size: .88rem; display: block; }
.form-grid label > input, .form-grid label > select, .form-grid label > textarea { margin-top: 6px; font-weight: 400; }
.form-grid .optional { color: var(--muted); font-weight: 400; }
.form-note { font-size: .82rem; color: var(--muted); margin: 0; }
.form-status { font-size: .92rem; font-weight: 600; margin: 0; }
.form-status.ok { color: var(--ok); }
.form-status.err { color: var(--danger); }
/* Honeypot: hidden from humans, present for bots */
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* YouTube thumbnail grabber */
.yt-title { font-weight: 700; font-size: 1.05rem; margin: 14px 0 0; line-height: 1.35; }
.yt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 18px; }
.yt-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.yt-card .thumb { position: relative; background: var(--bg); aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.yt-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-card .yt-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 9px; }
.yt-card .yt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.yt-card .yt-name { font-weight: 600; font-size: .9rem; }
.yt-card .yt-dim { font-family: var(--mono); font-size: .76rem; color: var(--muted); white-space: nowrap; }
.yt-card .yt-acts { display: flex; gap: 8px; }
.yt-card .yt-acts .btn { flex: 1; padding: 7px 10px; font-size: .84rem; }
.yt-grid .yt-card.hidden { display: none; }

/* Utility */
.hidden { display: none !important; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
