:root {
  color-scheme: light;
  --bg: #f6f7ef;
  --surface: #ffffff;
  --surface-soft: #f3f6e8;
  --ink: #192311;
  --muted: #66745c;
  --line: #d5dec3;
  --primary: #3f6f2a;
  --primary-strong: #254816;
  --accent: #dce86c;
  --danger: #a44336;
  --shadow: 0 8px 24px rgba(42, 62, 24, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  font-size: clamp(24px, 8vw, 34px);
  line-height: 1.12;
}

h2 {
  font-size: 16px;
}

.icon-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 24px;
  font-weight: 700;
}

.input-panel,
.saved-panel,
.result-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.segmented,
.tabs {
  display: grid;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

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

.segment,
.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segment.is-active,
.tab.is-active {
  color: #ffffff;
  background: var(--primary);
}

.mode-panel {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.mode-panel.is-hidden {
  display: none;
}

.event-form {
  display: grid;
  gap: 10px;
}

.grid {
  display: grid;
  gap: 10px;
}

.two,
.three {
  grid-template-columns: 1fr;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcf6;
  padding: 11px 12px;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

.artists-header,
.section-title,
.action-row,
.result-field-head,
.artist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.artists-header,
.section-title {
  justify-content: space-between;
}

.artist-rows {
  display: grid;
  gap: 8px;
}

.artist-row {
  align-items: end;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.artist-row label {
  min-width: 0;
}

.artist-row .time {
  flex: 0 0 112px;
}

.artist-row .artist {
  flex: 1 1 auto;
}

.remove-row {
  flex: 0 0 38px;
  width: 38px;
  height: 44px;
  border: 1px solid #e3c7c2;
  border-radius: 8px;
  color: var(--danger);
  background: #fff5f2;
  font-size: 20px;
}

.primary-button,
.secondary-button,
.text-button,
.copy-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #ffffff;
  background: var(--primary);
}

.align-end {
  align-self: end;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--primary-strong);
  background: var(--surface-soft);
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.text-button {
  min-height: 36px;
  border: 0;
  color: var(--danger);
  background: transparent;
  padding: 0 4px;
  font-size: 13px;
}

.copy-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--primary);
  color: var(--primary-strong);
  background: var(--accent);
  font-size: 13px;
}

.copy-button.is-copied {
  color: #ffffff;
  background: var(--primary);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
}

.fallback-panel {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.fallback-panel summary {
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.fallback-body {
  display: grid;
  gap: 10px;
  padding-top: 6px;
}

.status-line {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.event-choices {
  display: grid;
  gap: 8px;
}

.choice-button {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.choice-button.is-active {
  border-color: var(--primary);
  background: #eef5df;
}

.choice-button span {
  min-width: 34px;
  color: #ffffff;
  background: var(--primary);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.choice-button strong {
  color: var(--primary-strong);
  font-size: 13px;
}

.choice-button em {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-events {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-strong);
  background: var(--surface-soft);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 800;
}

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

.tab-panel {
  display: grid;
  gap: 13px;
}

.result-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcf6;
}

.result-field-head {
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.result-value {
  padding: 11px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.result-value.long {
  max-height: 280px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.artist-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.artist-name {
  color: var(--primary-strong);
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 10;
  transform: translateX(-50%) translateY(18px);
  max-width: calc(100% - 28px);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(25, 35, 17, 0.94);
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 14px;
  font-weight: 800;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

dialog {
  width: min(92vw, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.24);
}

dialog form {
  display: grid;
  gap: 12px;
}

dialog p {
  margin: 0;
  color: var(--muted);
}

@media (min-width: 600px) {
  .app-shell {
    padding-top: 28px;
  }

  .two {
    grid-template-columns: 180px 1fr;
  }

  .three {
    grid-template-columns: repeat(3, 1fr);
  }
}
