:root {
  color-scheme: light;
  --bg: #f7fbfa;
  --surface: #ffffff;
  --surface-soft: #edf6f3;
  --ink: #10201c;
  --muted: #61716c;
  --line: #d9e6e1;
  --teal: #057c70;
  --teal-dark: #075b54;
  --amber: #d9941e;
  --shadow: 0 22px 62px rgba(28, 50, 44, 0.12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1715;
  --surface: #16221f;
  --surface-soft: #20312d;
  --ink: #edf7f4;
  --muted: #a5b7b1;
  --line: #31433e;
  --teal: #19a896;
  --teal-dark: #7de0d2;
  --amber: #f1b84b;
  --shadow: 0 22px 62px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, transparent), transparent 380px),
    radial-gradient(circle at 84% 10%, color-mix(in srgb, var(--teal) 18%, transparent), transparent 340px),
    radial-gradient(circle at 72px 72px, color-mix(in srgb, var(--amber) 14%, transparent), transparent 180px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar,
.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 12px rgba(32, 53, 47, 0.16));
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 28px;
  line-height: 1.05;
}

.brand span span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 680;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button,
.swap-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 780;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.category-panel,
.converter-card,
.panel {
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.category-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.panel-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.panel-heading.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 300px;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.02;
}

h2 {
  font-size: 16px;
}

.panel-heading p,
.panel-heading span,
.converter-heading p,
.result-strip span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.category-list {
  display: grid;
  gap: 10px;
}

.unit-search {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.unit-search span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.unit-search input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 650;
}

.search-results {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.search-result {
  display: grid;
  gap: 3px;
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--teal) 8%, var(--surface));
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
}

.search-result strong {
  font-size: 13px;
}

.search-result span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.category-button {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--ink);
  padding: 0 10px;
  text-align: left;
}

.category-button svg {
  color: var(--teal);
}

.category-button strong,
.category-button span {
  display: block;
}

.category-button strong {
  font-size: 13px;
}

.category-button span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.category-button.active {
  border-color: var(--teal);
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
}

.category-button.active svg,
.category-button.active span {
  color: rgba(255, 255, 255, 0.78);
}

.category-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
  overflow: hidden;
}

.category-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  list-style: none;
}

.category-group summary::-webkit-details-marker {
  display: none;
}

.category-group summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.category-group[open] summary::after {
  transform: rotate(225deg);
}

.category-group summary strong {
  margin-left: auto;
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  color: var(--teal-dark);
  padding: 2px 7px;
  font-size: 11px;
}

.category-group-list {
  display: grid;
  gap: 7px;
  padding: 0 8px 8px;
}

.converter-area {
  display: grid;
  gap: 16px;
}

.converter-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 3vw, 30px);
}

.converter-card::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -80px;
  width: 260px;
  height: 260px;
  border: 32px solid color-mix(in srgb, var(--teal) 11%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.converter-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.converter-heading h2 {
  font-size: clamp(32px, 4.4vw, 56px);
  line-height: 1;
}

.precision-control {
  display: grid;
  gap: 5px;
  min-width: 132px;
}

.precision-control span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.precision-control select {
  border: 1px solid color-mix(in srgb, var(--teal) 30%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal-dark);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.conversion-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.unit-box {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  padding: 16px;
}

.unit-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

input,
select,
output {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.is-hidden {
  display: none !important;
}

input,
output {
  min-height: 68px;
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 820;
  line-height: 1;
}

.compound-input {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compound-input label {
  display: grid;
  gap: 5px;
}

.compound-input input {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 10px;
  font-size: 26px;
}

.compound-output {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compound-output strong {
  display: grid;
  place-items: center;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(26px, 4vw, 42px);
}

.compound-output strong span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

input:focus {
  outline: 0;
}

input:invalid {
  border-color: #b64a42;
  box-shadow: 0 0 0 3px rgba(182, 74, 66, 0.12);
}

.validation-message {
  margin: 0;
  color: #b64a42;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.35;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 0 10px;
}

.result-box {
  border-color: color-mix(in srgb, var(--teal) 34%, var(--line));
}

.swap-button {
  width: 72px;
  height: 72px;
  padding: 0;
  border-color: color-mix(in srgb, var(--teal) 26%, var(--line));
  background: color-mix(in srgb, var(--teal) 10%, var(--surface));
  color: var(--teal-dark);
}

.swap-button svg {
  width: 30px;
  height: 30px;
  stroke-width: 2.2;
}

.result-strip {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 5px;
  margin-top: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #fff;
  padding: 16px;
}

.result-strip span {
  color: rgba(255, 255, 255, 0.76);
}

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

.panel {
  padding: 16px;
  box-shadow: none;
}

.quick-grid,
.example-grid,
.recent-list {
  display: grid;
  gap: 8px;
}

.conversion-example,
.everyday-example,
.recent-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.conversion-example strong,
.conversion-example span,
.everyday-example strong,
.everyday-example span,
.recent-row strong,
.recent-row span {
  display: block;
}

.conversion-example strong,
.everyday-example strong,
.recent-row strong {
  font-size: 13px;
}

.conversion-example span,
.everyday-example span,
.recent-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.recent-row {
  display: grid;
  gap: 9px;
}

.recent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.text-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--teal-dark);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.about-panel {
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--amber) 14%, transparent), transparent 42%),
    color-mix(in srgb, var(--surface) 90%, var(--surface-soft));
}

.about-panel p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.about-note {
  margin-top: 14px;
  border-left: 4px solid var(--amber);
  padding: 10px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  color: var(--ink);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .workspace,
  .support-grid {
    grid-template-columns: 1fr;
  }

  .category-panel {
    position: static;
  }

  .category-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }

  .category-group-list {
    padding: 0 7px 7px;
  }

  .category-button {
    grid-template-columns: 24px 1fr;
  }

  .category-button svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand span span {
    display: none;
  }

  .icon-button {
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .conversion-grid {
    grid-template-columns: 1fr;
  }

  .category-list {
    grid-template-columns: 1fr;
  }

  .swap-button {
    width: 100%;
    height: 56px;
  }

  .converter-heading {
    display: grid;
  }

  .result-strip {
    position: sticky;
    bottom: 10px;
    z-index: 2;
  }
}
