:root {
  color-scheme: light dark;
  --ink: #151515;
  --muted: #62666f;
  --line: #d9dde5;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --panel-softer: #ffffff;
  --soft: #f4f6f8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #ecfdf5;
  --accent-line: #b7d8d4;
  --accent-ink: #ffffff;
  --warn: #b42318;
  --warn-soft: #fff3f1;
  --warn-line: #f3b0aa;
  --warn-strong: #8a1f17;
  --danger: var(--warn);
  --row-hover: #f1f8f6;
  --mono: #3b3f47;
  --strong-muted: #2f4858;
  --muted-soft: #f1f5f9;
  --muted-line: #cbd5e1;
  --tick-bg: #f9fafb;
  --tick-hit-line: #99d6ce;
  --tick-ghost: #ffffff;
  --track-bg: #eef2f7;
  --key-black: #202329;
  --key-black-active: #99f6e4;
  --tooltip-bg: #171717;
  --tooltip-ink: #ffffff;
  --wash: rgba(15, 118, 110, 0.08);
  --pulse: #f59e0b;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --shell-width: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4f1e8;
    --muted: #b8b1a6;
    --line: #3b3a36;
    --panel: #1b1c1d;
    --panel-soft: #232426;
    --panel-softer: #151617;
    --soft: #101112;
    --accent: #e4b45d;
    --accent-strong: #f4cf83;
    --accent-soft: #302817;
    --accent-line: #7a6134;
    --accent-ink: #17130a;
    --warn: #ffb3a3;
    --warn-soft: #351b18;
    --warn-line: #87463b;
    --warn-strong: #ffd0c7;
    --danger: var(--warn);
    --row-hover: #25231e;
    --mono: #d9d3c7;
    --strong-muted: #e0d7c6;
    --muted-soft: #202221;
    --muted-line: #484842;
    --tick-bg: #181a19;
    --tick-hit-line: #8d713f;
    --tick-ghost: #1c1e1d;
    --track-bg: #2b2c2b;
    --key-black: #07080a;
    --key-black-active: #f4cf83;
    --tooltip-bg: #080808;
    --tooltip-ink: #f4f1e8;
    --wash: rgba(228, 180, 93, 0.08);
    --pulse: #88d4c0;
    --shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
  }
}

:root[data-theme="dark"] {
  --ink: #f4f1e8;
  --muted: #b8b1a6;
  --line: #3b3a36;
  --panel: #1b1c1d;
  --panel-soft: #232426;
  --panel-softer: #151617;
  --soft: #101112;
  --accent: #e4b45d;
  --accent-strong: #f4cf83;
  --accent-soft: #302817;
  --accent-line: #7a6134;
  --accent-ink: #17130a;
  --warn: #ffb3a3;
  --warn-soft: #351b18;
  --warn-line: #87463b;
  --warn-strong: #ffd0c7;
  --danger: var(--warn);
  --row-hover: #25231e;
  --mono: #d9d3c7;
  --strong-muted: #e0d7c6;
  --muted-soft: #202221;
  --muted-line: #484842;
  --tick-bg: #181a19;
  --tick-hit-line: #8d713f;
  --tick-ghost: #1c1e1d;
  --track-bg: #2b2c2b;
  --key-black: #07080a;
  --key-black-active: #f4cf83;
  --tooltip-bg: #080808;
  --tooltip-ink: #f4f1e8;
  --wash: rgba(228, 180, 93, 0.08);
  --pulse: #88d4c0;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, var(--wash), transparent 34rem),
    var(--soft);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.4;
}

body.page-home {
  --shell-width: 960px;
}

body.page-tuning {
  --shell-width: 1220px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--accent-strong);
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

.shell {
  width: min(var(--shell-width), calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.page-home .shell {
  padding: 28px 0 44px;
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.home-link,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.home-link:hover,
.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 12px;
}

.top-links a,
.docs-link,
.open-link,
.open {
  color: var(--accent-strong);
  font-weight: 750;
  text-decoration: none;
}

.top-links a:hover,
.docs-link:hover,
.open-link:hover,
.open:hover {
  color: var(--accent);
}

.tool,
.panel,
section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tool {
  color: inherit;
  text-decoration: none;
}

.tool:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

section h2 {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

label,
.field span,
.option-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-softer);
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary,
#analyze {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.primary:hover,
#analyze:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.secondary,
.button-link,
.mini-button,
.toggle-button,
#estimate-key,
#share,
#play-chord {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent-strong);
}

.secondary:hover,
.button-link:hover,
.mini-button:hover,
.toggle-button:hover,
.toggle-button.active,
.toggle-button.copied,
#estimate-key:hover,
#share:hover,
#share.copied,
#play-chord:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button:disabled,
button[disabled] {
  cursor: not-allowed;
  opacity: 0.62;
}

.chip,
.guitar-note {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
}

.error {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn-strong);
}

table {
  border-collapse: collapse;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
}

th,
td {
  border-bottom: 1px solid var(--line);
}

tbody tr:hover {
  background: var(--row-hover);
}

.fact {
  border-color: var(--line);
  background: var(--panel-softer);
}

.fact span {
  color: var(--muted);
}

.help {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.help::after {
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
}

:root[data-theme="dark"] .guitar-chart svg text,
:root[data-theme="dark"] #notation svg [fill="#000"],
:root[data-theme="dark"] #notation svg [fill="#000000"],
:root[data-theme="dark"] #notation svg [fill="black"],
:root[data-theme="dark"] #chord-notation svg [fill="#000"],
:root[data-theme="dark"] #chord-notation svg [fill="#000000"],
:root[data-theme="dark"] #chord-notation svg [fill="black"],
:root[data-theme="dark"] #rhythm-notation svg [fill="#000"],
:root[data-theme="dark"] #rhythm-notation svg [fill="#000000"],
:root[data-theme="dark"] #rhythm-notation svg [fill="black"] {
  fill: var(--ink) !important;
}

:root[data-theme="dark"] .guitar-chart svg [fill="#000"],
:root[data-theme="dark"] .guitar-chart svg [fill="#000000"],
:root[data-theme="dark"] .guitar-chart svg [fill="black"] {
  fill: var(--ink);
}

:root[data-theme="dark"] .guitar-chart svg [stroke="#000"],
:root[data-theme="dark"] .guitar-chart svg [stroke="#000000"],
:root[data-theme="dark"] .guitar-chart svg [stroke="black"],
:root[data-theme="dark"] #notation svg [stroke="#000"],
:root[data-theme="dark"] #notation svg [stroke="#000000"],
:root[data-theme="dark"] #notation svg [stroke="black"],
:root[data-theme="dark"] #chord-notation svg [stroke="#000"],
:root[data-theme="dark"] #chord-notation svg [stroke="#000000"],
:root[data-theme="dark"] #chord-notation svg [stroke="black"],
:root[data-theme="dark"] #rhythm-notation svg [stroke="#000"],
:root[data-theme="dark"] #rhythm-notation svg [stroke="#000000"],
:root[data-theme="dark"] #rhythm-notation svg [stroke="black"] {
  stroke: var(--ink) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .guitar-chart svg text,
  :root:not([data-theme="light"]) #notation svg [fill="#000"],
  :root:not([data-theme="light"]) #notation svg [fill="#000000"],
  :root:not([data-theme="light"]) #notation svg [fill="black"],
  :root:not([data-theme="light"]) #chord-notation svg [fill="#000"],
  :root:not([data-theme="light"]) #chord-notation svg [fill="#000000"],
  :root:not([data-theme="light"]) #chord-notation svg [fill="black"],
  :root:not([data-theme="light"]) #rhythm-notation svg [fill="#000"],
  :root:not([data-theme="light"]) #rhythm-notation svg [fill="#000000"],
  :root:not([data-theme="light"]) #rhythm-notation svg [fill="black"] {
    fill: var(--ink) !important;
  }

  :root:not([data-theme="light"]) .guitar-chart svg [fill="#000"],
  :root:not([data-theme="light"]) .guitar-chart svg [fill="#000000"],
  :root:not([data-theme="light"]) .guitar-chart svg [fill="black"] {
    fill: var(--ink);
  }

  :root:not([data-theme="light"]) .guitar-chart svg [stroke="#000"],
  :root:not([data-theme="light"]) .guitar-chart svg [stroke="#000000"],
  :root:not([data-theme="light"]) .guitar-chart svg [stroke="black"],
  :root:not([data-theme="light"]) #notation svg [stroke="#000"],
  :root:not([data-theme="light"]) #notation svg [stroke="#000000"],
  :root:not([data-theme="light"]) #notation svg [stroke="black"],
  :root:not([data-theme="light"]) #chord-notation svg [stroke="#000"],
  :root:not([data-theme="light"]) #chord-notation svg [stroke="#000000"],
  :root:not([data-theme="light"]) #chord-notation svg [stroke="black"],
  :root:not([data-theme="light"]) #rhythm-notation svg [stroke="#000"],
  :root:not([data-theme="light"]) #rhythm-notation svg [stroke="#000000"],
  :root:not([data-theme="light"]) #rhythm-notation svg [stroke="black"] {
    stroke: var(--ink) !important;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 24px, var(--shell-width));
    padding-top: 16px;
  }

  header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .top-links {
    justify-content: start;
    gap: 8px;
    width: 100%;
  }

  .top-links a,
  .docs-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .theme-toggle {
    justify-self: start;
  }
}
