:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1c211f;
  --muted: #59635f;
  --line: #d9ddd8;
  --accent: #12664f;
  --accent-strong: #0d4d3c;
  --accent-soft: #dcefe8;
  --warning: #9b4b14;
  --warning-soft: #f7e6d9;
  --danger: #9d2f32;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Yu Gothic UI",
    "Hiragino Sans",
    "Meiryo",
    system-ui,
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 2vw, 2.25rem);
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  gap: 28px;
  align-items: start;
}

.editor-pane,
.result-pane {
  min-width: 0;
}

.section-heading,
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.choice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
}

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

.choice-row input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
}

.choice-row input:focus,
.toggle-row input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.remove-button,
.secondary-button,
.primary-button {
  height: 44px;
  border-radius: 8px;
}

.remove-button {
  background: transparent;
  color: var(--danger);
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  color: var(--ink);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.result-pane {
  padding-left: 2px;
}

.url-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.url-status.warning {
  color: var(--warning);
}

.url-meter {
  margin-top: 16px;
}

.url-meter-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.url-meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e8e4;
}

.url-meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 120ms ease, background 120ms ease;
}

.url-meter-fill.warning {
  background: var(--warning);
}

.url-meter-fill.over-limit {
  background: var(--danger);
}

.url-meter-copy {
  min-height: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.url-meter-copy.warning {
  color: var(--warning);
}

.result-display {
  display: grid;
  align-content: center;
  min-height: 188px;
  margin-bottom: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result-label {
  overflow-wrap: anywhere;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
  line-height: 1.35;
}

.result-meta {
  min-height: 24px;
  margin-top: 10px;
  color: var(--muted);
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  background: #9ca7a2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  body {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    width: min(100%, calc(100% - 24px));
    height: 100dvh;
    min-height: 100dvh;
    padding: 20px 0 24px;
    display: flex;
    flex-direction: column;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }

  .workspace {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
  }

  .result-pane {
    order: -1;
  }

  .result-display {
    min-height: 132px;
    margin-bottom: 12px;
    padding: 18px;
  }

  .editor-pane {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  .section-heading {
    margin-bottom: 12px;
  }

  .choice-list {
    min-height: 0;
    flex: 1;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
  }

  .toggle-row {
    margin-top: 14px;
  }
}

@media (max-width: 520px) {
  .choice-row {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .result-header {
    align-items: start;
    flex-direction: column;
  }

  .url-status {
    text-align: left;
  }

  .url-meter-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }
}
