:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #15201b;
  --muted: #617069;
  --line: #dce3df;
  --accent: #197a63;
  --accent-strong: #0f604d;
  --warn: #a15420;
  --soft: #edf5f2;
  --nav: #101a16;
  --nav-muted: #9fb0a9;
  --shadow: 0 18px 60px rgba(21, 32, 27, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button:hover:not(:disabled) {
  border-color: var(--accent-strong);
}

button.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  background: var(--nav);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 900;
}

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

.brand small {
  margin-top: 3px;
  color: var(--nav-muted);
  font-size: 0.82rem;
}

.converter-nav {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.nav-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-color: transparent;
  background: transparent;
  color: var(--nav-muted);
  text-align: left;
  padding: 0 10px;
}

.nav-item:hover:not(:disabled),
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(10, 16, 13, 0.48);
}

.app {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 40px;
}

.app-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.menu-button {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.8rem, 4vw, 3.3rem);
  line-height: 1;
}

p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero {
  min-height: calc(100vh - 160px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: clamp(28px, 5vw, 58px);
  display: grid;
  align-content: center;
  justify-items: start;
}

.hero-copy p {
  max-width: 620px;
  font-size: 1.08rem;
  line-height: 1.6;
}

.hero-copy .primary {
  margin-top: 24px;
}

.hero-panel {
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.converter-card {
  width: 100%;
  min-height: 112px;
  display: grid;
  gap: 8px;
  align-content: center;
  text-align: left;
  padding: 18px;
}

.converter-card span {
  font-size: 1.18rem;
}

.converter-card small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.converter-card.is-muted {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfb;
  color: var(--muted);
}

.workspace {
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.dropzone {
  min-height: 250px;
  margin: 28px;
  border: 2px dashed #aac0b7;
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: #f6fbf9;
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 2rem;
}

.dropzone strong {
  color: var(--ink);
  font-size: 1.35rem;
}

.controls {
  display: grid;
  grid-template-columns: 110px 110px 1fr 1fr;
  gap: 12px;
  align-items: stretch;
  padding: 0 28px 22px;
}

.settings-panel {
  margin: 0 28px 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  display: grid;
  gap: 16px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: min(420px, 100%);
}

.mode-switch label {
  position: relative;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.mode-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-switch label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr);
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.field input[type="range"] {
  padding: 0;
}

.unit-panel {
  margin-top: 28px;
}

.unit-category-field {
  width: min(360px, 100%);
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.unit-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.unit-message,
.unit-formula {
  margin: 0;
  min-height: 1.35em;
  font-size: 0.95rem;
}

.unit-message {
  color: var(--warn);
  font-weight: 700;
}

.unit-formula {
  color: var(--muted);
}

.stat {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  display: grid;
  align-content: center;
}

.stat span {
  font-weight: 800;
  font-size: 1.2rem;
}

.stat small {
  color: var(--muted);
}

.progress {
  height: 6px;
  background: #edf1ee;
  overflow: hidden;
}

#progressBar {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 430px;
  overflow: auto;
}

.file-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 86px;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #edf1ee center / cover no-repeat;
  border: 1px solid var(--line);
}

.file-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-status {
  color: var(--muted);
  font-size: 0.92rem;
}

.file-row.is-error .file-status {
  color: var(--warn);
}

.download-one {
  width: 86px;
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(320px, 86vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .menu-button {
    display: grid;
    place-items: center;
  }

  .app {
    width: min(960px, calc(100% - 32px));
  }

  .hero {
    min-height: auto;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app {
    width: 100%;
    padding: 0;
  }

  .app-header {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .hero {
    gap: 0;
  }

  .hero-copy,
  .hero-panel,
  .workspace {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .hero-panel {
    border-top: 0;
  }

  .topbar,
  .dropzone,
  .settings-panel,
  .controls,
  .file-row {
    margin-left: 16px;
    margin-right: 16px;
    padding-left: 0;
    padding-right: 0;
  }

  .topbar {
    padding-top: 22px;
  }

  .dropzone {
    min-height: 210px;
  }

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

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

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

  .unit-grid,
  .unit-actions {
    grid-template-columns: 1fr;
  }

  .file-row {
    grid-template-columns: 48px minmax(0, 1fr) 72px;
    gap: 10px;
  }

  .download-one {
    width: 72px;
    padding: 0 10px;
  }
}
