/* Gadget Hubly — shared design system (v2, 2026) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

/* ---------- tokens ---------- */
:root {
  --font-sans: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #faf7f4;
  --bg-elev: #ffffff;
  --bg-sunken: #f1ece7;
  --text: #2a2320;
  --text-soft: #6c625b;
  --text-faint: #9a8f86;
  --border: #e7ded6;
  --border-strong: #d8ccc0;

  --accent: #d97845;
  --accent-hover: #c4693a;
  --accent-soft: #fbeee6;
  --accent-contrast: #ffffff;

  --ok: #2f9e6e;
  --warn: #d98a1f;
  --danger: #d9534f;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(42, 35, 32, .06), 0 1px 3px rgba(42, 35, 32, .04);
  --shadow-md: 0 4px 12px rgba(42, 35, 32, .08), 0 2px 4px rgba(42, 35, 32, .04);
  --maxw: 760px;
  --maxw-wide: 1040px;
}

:root[data-theme="dark"] {
  --bg: #191512;
  --bg-elev: #221d19;
  --bg-sunken: #14100e;
  --text: #f0e9e3;
  --text-soft: #b8aaa0;
  --text-faint: #8a7d73;
  --border: #352d27;
  --border-strong: #463c34;

  --accent: #e88a58;
  --accent-hover: #f0996a;
  --accent-soft: #2c2019;
  --accent-contrast: #1a1410;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191512;
    --bg-elev: #221d19;
    --bg-sunken: #14100e;
    --text: #f0e9e3;
    --text-soft: #b8aaa0;
    --text-faint: #8a7d73;
    --border: #352d27;
    --border-strong: #463c34;
    --accent: #e88a58;
    --accent-hover: #f0996a;
    --accent-soft: #2c2019;
    --accent-contrast: #1a1410;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .4);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.7rem; margin: 0 0 .5em; }
h2 { font-size: 1.25rem; margin: 2em 0 .7em; }
h3 { font-size: 1.05rem; margin: 1.6em 0 .5em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.4em; }
li { margin: .3em 0; }
code {
  font-family: var(--font-mono);
  font-size: .9em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: .1em .4em;
  border-radius: 6px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.gh-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 20px 80px;
}
.gh-main.wide { max-width: var(--maxw-wide); }

/* ---------- header ---------- */
.gh-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.gh-header-inner {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.gh-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  color: var(--text);
  font-size: 1.02rem;
}
.gh-brand:hover { text-decoration: none; }
.gh-brand img { width: 30px; height: 30px; border-radius: 7px; }
.gh-header-spacer { flex: 1; }
.gh-iconbtn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.gh-iconbtn:hover { background: var(--bg-sunken); color: var(--text); }
.gh-langlink {
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.gh-langlink:hover { text-decoration: none; background: var(--bg-sunken); color: var(--text); }

/* ---------- footer ---------- */
.gh-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.gh-footer-inner {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  font-size: .85rem;
  color: var(--text-soft);
}
.gh-footer a { color: var(--text-soft); }
.gh-footer a:hover { color: var(--text); }
.gh-footer .gh-copy { flex: 1 1 100%; color: var(--text-faint); }

/* ---------- hero (index) ---------- */
.gh-hero { text-align: center; padding: 20px 0 8px; }
.gh-hero img { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 18px; }
.gh-hero h1 { font-size: 2rem; margin-bottom: .3em; }
.gh-hero p { color: var(--text-soft); max-width: 46ch; margin: 0 auto; }

/* ---------- tool card grid ---------- */
.gh-cat { margin-top: 40px; }
.gh-cat-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 1.1rem;
  margin: 0 0 14px;
}
.gh-cat-title span { font-size: .8rem; color: var(--text-faint); font-weight: 500; }
.gh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.gh-card {
  display: block;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.gh-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.gh-card-emoji { font-size: 1.5rem; line-height: 1; }
.gh-card-title { font-weight: 700; color: var(--text); margin: 10px 0 4px; }
.gh-card-desc { font-size: .87rem; color: var(--text-soft); line-height: 1.6; margin: 0; }
.gh-badge-new {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ---------- tool page scaffold ---------- */
.gh-back {
  font-size: .85rem;
  color: var(--text-soft);
  display: inline-flex;
  gap: 5px;
  margin-bottom: 14px;
}
.gh-tool-head { margin-bottom: 8px; }
.gh-tool-head p.lead { color: var(--text-soft); margin-top: -.2em; }
.gh-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  margin: 20px 0;
}
.gh-prose { color: var(--text); }
.gh-prose h2:first-child { margin-top: 0; }

/* ---------- form controls ---------- */
.gh-field { margin: 14px 0; }
.gh-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
select { cursor: pointer; }

.gh-btn {
  appearance: none;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  white-space: nowrap;
  transition: background .15s, transform .05s;
}
.gh-btn:hover { background: var(--accent-hover); text-decoration: none; }
.gh-btn:active { transform: translateY(1px); }
.gh-btn.ghost {
  background: transparent;
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.gh-btn.ghost:hover { background: var(--bg-sunken); color: var(--text); }
.gh-btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.gh-radio-row, .gh-check-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.gh-radio-row label, .gh-check-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .92rem; cursor: pointer;
}

/* ---------- stat table / readouts ---------- */
.gh-stats { width: 100%; border-collapse: collapse; }
.gh-stats th, .gh-stats td {
  text-align: left;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.gh-stats th { font-weight: 500; color: var(--text-soft); }
.gh-stats td { font-variant-numeric: tabular-nums; font-weight: 600; }
.gh-stats tr:last-child th, .gh-stats tr:last-child td { border-bottom: none; }

.gh-readout {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 1;
  color: var(--text);
  margin: 6px 0;
}
.gh-readout small { display: block; font-size: .9rem; font-weight: 500; color: var(--text-faint); margin-top: 8px; }

/* ---------- big tap surface ---------- */
.gh-tap {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 100%;
  max-width: 320px;
  aspect-ratio: 3 / 2;
  margin: 18px auto;
  border-radius: var(--radius);
  border: 2px dashed var(--border-strong);
  background: var(--bg-sunken);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: background .08s, border-color .08s, transform .06s;
}
.gh-tap.hit { background: var(--accent-soft); border-color: var(--accent); transform: scale(.985); }
.gh-tap.locked { opacity: .55; cursor: default; }

/* ---------- misc helpers ---------- */
.gh-muted { color: var(--text-soft); font-size: .9rem; }
.gh-hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.gh-faq dt { font-weight: 700; margin-top: 1em; }
.gh-faq dd { margin: .3em 0 0; color: var(--text-soft); }
.gh-copywrap { display: flex; gap: 8px; align-items: center; }
.gh-copywrap code { flex: 1; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
.gh-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.gh-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- music tools: note chips + piano keyboard (music.js) ---------- */
.gh-noterow { display: flex; flex-wrap: wrap; gap: 6px; }
.gh-note {
  appearance: none; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-elev);
  color: var(--text); font: inherit; font-weight: 600;
  border-radius: 8px; padding: 8px 0; min-width: 44px; flex: 1;
}
.gh-note:hover { background: var(--bg-sunken); }
.gh-note.sel { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

.gh-kb {
  position: relative; display: flex; height: 200px; margin: 16px 0 6px;
  border: 1px solid #b7b0a8; border-radius: 8px; overflow: hidden;
  background: #ded9d3; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.gh-kb-key { position: relative; box-sizing: border-box; cursor: pointer; }
.gh-kb-white { background: #fbfaf9; border-right: 1px solid #c9c3bb; }
.gh-kb-white:last-child { border-right: none; }
.gh-kb-white.on { background: #f3b78e; }
.gh-kb-white.root.on { background: #ec9a63; box-shadow: inset 0 0 0 3px #c4693a; }
.gh-kb-black {
  position: absolute; top: 0; height: 62%;
  background: #2c2825; border: 1px solid #000; border-top: none;
  border-radius: 0 0 5px 5px; z-index: 3;
}
.gh-kb-black.on { background: #d97845; }
.gh-kb-black.root.on { background: #c4693a; box-shadow: inset 0 0 0 2px #7a3d1f; }
.gh-kb-key.hit { filter: brightness(0.82); }
.gh-kb-lbl {
  position: absolute; left: 0; right: 0; bottom: 7px; text-align: center;
  font-size: .68rem; font-weight: 700; pointer-events: none;
}
.gh-kb-white .gh-kb-lbl { color: #9a4a22; }
.gh-kb-black .gh-kb-lbl { color: #fff; bottom: 5px; }


@media (max-width: 560px) {
  h1 { font-size: 1.45rem; }
  .gh-hero h1 { font-size: 1.7rem; }
  .gh-main { padding: 24px 16px 64px; }
  .gh-panel { padding: 18px; }
  .gh-readout { font-size: 2.6rem; }
}
