:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #15202b;
  --muted: #647383;
  --line: #dbe3ea;
  --brand: #1565c0;
  --brand-2: #00a896;
  --brand-soft: #e9f3ff;
  --danger: #c62828;
  --success: #087f5b;
  --shadow: 0 16px 42px rgba(20, 37, 55, .08);
  --radius: 20px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d141b;
  --surface: #141e28;
  --surface-soft: #1b2834;
  --text: #edf4fa;
  --muted: #9aabba;
  --line: #2a3b49;
  --brand: #6eb6ff;
  --brand-2: #58d5c7;
  --brand-soft: #17314a;
  --danger: #ff8a80;
  --success: #70dfbd;
  --shadow: 0 18px 46px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  line-height: 1.65;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.shell { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.site-header {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}
.header-inner { min-height: 68px; display: flex; align-items: center; gap: 14px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 850; letter-spacing: -.04em; font-size: 1.2rem; }
.logo-mark { display: grid; place-items: center; width: 36px; aspect-ratio: 1; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 25%, transparent); }
.header-spacer { flex: 1; }
.icon-button, .favorite-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); min-width: 42px; height: 42px; border-radius: 12px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-button:hover, .favorite-button:hover { border-color: var(--brand); }
.favorite-button.active { color: #f6a700; background: #fff8df; border-color: #f3cc67; }
.hero { padding: 70px 0 34px; text-align: center; }
.eyebrow { color: var(--brand); font-weight: 800; letter-spacing: .08em; font-size: .78rem; text-transform: uppercase; }
.hero h1 { margin: 10px 0 12px; font-size: clamp(2.45rem, 8vw, 5.6rem); line-height: .98; letter-spacing: -.075em; }
.hero h1 span { color: var(--brand); }
.hero p { max-width: 660px; margin: 0 auto; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); }
.search-wrap { position: relative; max-width: 720px; margin: 30px auto 0; }
.search-wrap input { width: 100%; height: 60px; border: 1px solid var(--line); border-radius: 18px; padding: 0 58px 0 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: none; }
.search-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent), var(--shadow); }
.search-hint { position: absolute; right: 14px; top: 50%; translate: 0 -50%; color: var(--muted); font-size: .8rem; border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px; }
.privacy-strip { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px 26px; margin-top: 22px; color: var(--muted); font-size: .88rem; }
.privacy-strip span::before { content: "✓"; color: var(--success); font-weight: 900; margin-right: 6px; }
.category-nav { display: flex; gap: 8px; padding: 12px 0 22px; overflow-x: auto; scrollbar-width: none; }
.category-nav::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 9px 15px; cursor: pointer; }
.chip:hover, .chip.active { color: #fff; border-color: var(--brand); background: var(--brand); }
.section { padding: 20px 0 48px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: clamp(1.35rem, 4vw, 1.85rem); letter-spacing: -.035em; }
.section-head p { margin: 0; color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tool-card { position: relative; display: flex; min-height: 155px; flex-direction: column; gap: 8px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.tool-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); box-shadow: var(--shadow); }
.tool-card h3 { margin: 0; padding-right: 36px; font-size: 1.05rem; letter-spacing: -.02em; }
.tool-card p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.tool-card .category-label { margin-top: auto; color: var(--brand); font-size: .75rem; font-weight: 750; }
.card-favorite { position: absolute; right: 13px; top: 13px; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.15rem; }
.card-favorite.active { color: #efa800; }
.empty-state { grid-column: 1 / -1; padding: 46px 20px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.site-footer { margin-top: 30px; border-top: 1px solid var(--line); padding: 28px 0 42px; color: var(--muted); font-size: .86rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Tool page */
.tool-breadcrumb { padding: 24px 0 8px; color: var(--muted); font-size: .86rem; }
.tool-breadcrumb a { color: var(--brand); text-decoration: none; }
.tool-title-row { display: flex; align-items: flex-start; gap: 16px; padding: 18px 0 24px; }
.tool-title-row h1 { margin: 0; font-size: clamp(1.75rem, 6vw, 2.8rem); line-height: 1.18; letter-spacing: -.045em; }
.tool-title-row p { margin: 8px 0 0; color: var(--muted); }
.tool-title-row .favorite-button { margin-left: auto; flex: 0 0 auto; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 20px; align-items: start; padding-bottom: 46px; }
.tool-panel, .side-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.tool-panel { padding: clamp(18px, 4vw, 30px); min-height: 410px; }
.side-stack { display: grid; gap: 14px; }
.side-card { padding: 19px; box-shadow: none; }
.side-card h2 { margin: 0 0 10px; font-size: 1rem; }
.side-card p, .side-card li { color: var(--muted); font-size: .86rem; }
.side-card ul { margin: 0; padding-left: 20px; }
.related-list { display: grid; gap: 7px; }
.related-list a { padding: 10px 11px; border-radius: 10px; background: var(--surface-soft); text-decoration: none; font-size: .88rem; }
.related-list a:hover { color: var(--brand); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { font-weight: 750; font-size: .88rem; }
.field small { color: var(--muted); }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); color: var(--text); outline: none;
}
textarea { min-height: 150px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 13%, transparent); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.button { min-height: 44px; border: 1px solid var(--brand); border-radius: 12px; padding: 9px 17px; background: var(--brand); color: #fff; font-weight: 750; cursor: pointer; }
.button:hover { filter: brightness(1.06); }
.button.secondary { background: var(--surface); color: var(--brand); }
.button.ghost { border-color: var(--line); background: transparent; color: var(--muted); }
.button.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.result-box { margin-top: 20px; padding: 18px; border-radius: 15px; border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--line)); background: var(--brand-soft); overflow-wrap: anywhere; }
.result-box:empty { display: none; }
.result-box strong.result-main { display: block; font-size: clamp(1.45rem, 5vw, 2.2rem); color: var(--brand); line-height: 1.3; }
.result-box pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.error-box { display: none; margin-top: 14px; padding: 12px 14px; border-radius: 11px; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.error-box.show { display: block; }
.status-note { color: var(--muted); font-size: .84rem; margin-top: 12px; }
.big-display { text-align: center; font-variant-numeric: tabular-nums; font-size: clamp(3.2rem, 13vw, 7.4rem); line-height: 1.1; font-weight: 850; letter-spacing: -.065em; padding: 35px 5px; }
.sub-display { text-align: center; color: var(--muted); font-size: 1rem; }
.list-editor { display: grid; gap: 9px; margin-top: 18px; }
.list-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); }
.list-item.done .item-text { color: var(--muted); text-decoration: line-through; }
.list-item .item-text { flex: 1; overflow-wrap: anywhere; }
.list-item button { border: 0; background: transparent; color: var(--danger); cursor: pointer; }
.preview-canvas, .image-preview { display: block; max-width: 100%; max-height: 520px; margin: 18px auto 0; border: 1px solid var(--line); border-radius: 12px; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 / 18px 18px; }
.table-wrap { overflow: auto; margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--surface-soft); position: sticky; top: 0; }
.color-swatch { min-height: 80px; border-radius: 14px; margin-top: 14px; border: 1px solid var(--line); }
.timer-progress { height: 9px; background: var(--surface-soft); border-radius: 99px; overflow: hidden; }
.timer-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.health-disclaimer { margin-top: 18px; padding: 12px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: .8rem; }
.tool-actions { display: flex; gap: 9px; margin-top: 14px; flex-wrap: wrap; }

/* Original dashboard treatment for time tools */
body[data-tool="clock"] .time-stage, body[data-tool="timer"] .time-stage, body[data-tool="stopwatch"] .time-stage, body[data-tool="interval-timer"] .time-stage, body[data-tool="pomodoro"] .time-stage {
  position: relative; display: grid; place-content: center; min-height: 300px; overflow: hidden;
  border: 1px solid #173a63; border-radius: 18px; background: radial-gradient(circle at 78% 18%, #1c6096 0, transparent 32%), linear-gradient(135deg, #102a46, #0a1727); color: #fff;
}
body[data-tool="clock"] .time-stage::before, body[data-tool="timer"] .time-stage::before, body[data-tool="stopwatch"] .time-stage::before, body[data-tool="interval-timer"] .time-stage::before, body[data-tool="pomodoro"] .time-stage::before { content: "LIVE / TIME"; position: absolute; top: 16px; left: 18px; color: #89d2ff; font-size: .7rem; font-weight: 800; letter-spacing: .16em; }
body[data-tool="clock"] .time-stage::after, body[data-tool="timer"] .time-stage::after, body[data-tool="stopwatch"] .time-stage::after, body[data-tool="interval-timer"] .time-stage::after, body[data-tool="pomodoro"] .time-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(to bottom, #000, transparent); }
body[data-tool="clock"] .time-stage > *, body[data-tool="timer"] .time-stage > *, body[data-tool="stopwatch"] .time-stage > *, body[data-tool="interval-timer"] .time-stage > *, body[data-tool="pomodoro"] .time-stage > * { position: relative; z-index: 1; }
body[data-tool="clock"] .time-stage .big-display, body[data-tool="timer"] .time-stage .big-display, body[data-tool="stopwatch"] .time-stage .big-display, body[data-tool="interval-timer"] .time-stage .big-display, body[data-tool="pomodoro"] .time-stage .big-display { padding: 0 18px; color: #f8fbff; text-shadow: 0 0 28px rgba(92, 201, 255, .38); font-size: clamp(3rem, 8vw, 6.2rem); }
body[data-tool="stopwatch"] .time-stage .big-display { font-size: clamp(2.5rem, 6.3vw, 4.8rem); }
body[data-tool="clock"] .time-stage .sub-display, body[data-tool="timer"] .time-stage .sub-display, body[data-tool="stopwatch"] .time-stage .sub-display, body[data-tool="interval-timer"] .time-stage .sub-display, body[data-tool="pomodoro"] .time-stage .sub-display { color: #b9dbf3; }
.time-controls, .time-settings { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.time-settings .field-grid { grid-template-columns: minmax(0, 1fr); }
.time-controls .field-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.time-controls .button-row { margin-top: 16px; }
.time-stage .timer-progress { position: absolute; z-index: 2; right: 18px; bottom: 18px; left: 18px; background: rgba(255,255,255,.16); }
.time-stage .timer-progress span { background: linear-gradient(90deg, #5cceff, #80f0c4); }
@media (max-width: 580px) { .time-stage { min-height: 245px !important; } .time-controls, .time-settings { padding: 14px; } }

@media (max-width: 880px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  .shell { width: min(100% - 22px, 1180px); }
  .hero { padding-top: 45px; }
  .tool-grid, .field-grid, .side-stack { grid-template-columns: 1fr; }
  .tool-card { min-height: 136px; }
  .search-hint { display: none; }
  .tool-title-row { align-items: center; }
  .header-inner { min-height: 60px; }
  .logo-mark { width: 33px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
