:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-2: #eef5f2;
  --text: #23302d;
  --muted: #6d7f79;
  --line: #d9e4df;
  --mint: #8fbfb1;
  --mint-dark: #527d72;
  --blue: #5a86a5;
  --danger: #b96b6b;
  --shadow: 0 18px 40px rgba(32, 52, 46, 0.10);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(143, 191, 177, 0.20), transparent 34%),
    linear-gradient(180deg, #fbfcfc 0%, var(--bg) 100%);
  font-family: "Segoe UI", "Noto Sans JP", system-ui, -apple-system, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  margin-bottom: 18px;
  border: 1px solid rgba(217, 228, 223, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.lead {
  max-width: 780px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.language-picker select {
  min-width: 112px;
  border: 0;
  color: var(--text);
  background: transparent;
  outline: none;
  font-weight: 800;
  cursor: pointer;
}


.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.main-panel {
  min-height: 720px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f9fbfa);
}

.panel-head.compact {
  padding: 18px;
}

.subtext {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.file-picker input {
  display: none;
}

.file-picker span,
.primary-btn,
.accent-btn,
.ghost-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.file-picker span,
.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--mint-dark), var(--blue));
  box-shadow: 0 10px 20px rgba(82, 125, 114, 0.22);
}

.accent-btn {
  color: #fff;
  background: linear-gradient(135deg, #76aa9b, #8fbfb1);
}

.ghost-btn {
  color: var(--mint-dark);
  border: 1px solid var(--line);
  background: #fff;
}

.danger-btn {
  color: #fff;
  background: var(--danger);
}

.wide {
  width: 100%;
}

.file-picker span:hover,
.primary-btn:hover:not(:disabled),
.accent-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.danger-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.transport {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.time-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin-left: auto;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.wave-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.wave-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.wave-toolbar input[type="range"] {
  width: 180px;
  accent-color: var(--mint-dark);
}

#zoomLabel {
  min-width: 96px;
  color: var(--mint-dark);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.wave-viewport {
  position: relative;
  height: 520px;
  margin: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(217, 228, 223, 0.55) 1px, transparent 1px),
    linear-gradient(180deg, #ffffff, #f8fbfa);
  background-size: 72px 100%, 100% 100%;
  overflow: hidden;
  user-select: none;
  outline: none;
}

.wave-viewport:focus-visible {
  box-shadow: 0 0 0 4px rgba(143, 191, 177, 0.25);
}

#waveCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-wave {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
}

.side-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.marker-list,
.segment-preview {
  max-height: 240px;
  overflow: auto;
  padding: 12px;
}

.marker-item,
.segment-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.marker-item + .marker-item,
.segment-item + .segment-item {
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--mint-dark);
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.marker-time,
.segment-meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.segment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.icon-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-weight: 900;
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
}

.small-btn {
  min-width: 34px;
  min-height: 32px;
  padding: 0 10px;
}

.empty-list {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.field-label {
  display: block;
  padding: 16px 18px 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(143, 191, 177, 0.16);
}

textarea {
  display: block;
  min-height: 120px;
  margin: 0 18px 14px;
  width: calc(100% - 36px);
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 108px;
  gap: 10px;
  padding: 0 18px 14px;
}

.settings-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.settings-grid input {
  height: 42px;
  padding: 0 12px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 18px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.check-row input {
  margin-top: 4px;
  accent-color: var(--mint-dark);
}

#exportBtn {
  margin: 4px 18px 12px;
  width: calc(100% - 36px);
}

.export-status {
  margin: 0 18px 18px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 0.9rem;
  line-height: 1.6;
}

.preview-panel {
  min-height: 220px;
}

dialog {
  width: min(720px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  padding: 0;
}

dialog::backdrop {
  background: rgba(22, 32, 30, 0.45);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfa;
}

.dialog-head h2 {
  margin: 0;
}

.dialog-body {
  padding: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.dialog-body p,
.dialog-body ul {
  margin-bottom: 18px;
}

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

  .side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-column .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .app-header,
  .panel-head,
  .transport,
  .wave-toolbar,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .time-box {
    margin-left: 0;
    justify-content: center;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .side-column .panel:last-child {
    grid-column: auto;
  }

  .wave-viewport {
    height: 380px;
    margin: 12px;
  }

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

.settings-block {
  margin: 0 18px 14px;
  padding: 12px 0 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdfc;
}

.inner-label {
  padding: 0 14px 8px;
}

.compact-check {
  padding: 0 14px 8px;
}

.settings-input {
  display: block;
  width: calc(100% - 28px);
  height: 42px;
  margin: 0 14px 10px;
  padding: 0 12px;
}

.settings-input:disabled {
  background: #eef5f2;
  color: var(--muted);
}

.range-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 64px;
  align-items: center;
  gap: 10px;
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--mint-dark);
}

.range-row strong {
  color: var(--mint-dark);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.segment-item.is-muted {
  opacity: 0.45;
  background: #f6f8f7;
}

.segment-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.segment-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--mint-dark);
  background: var(--panel-2);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .range-row {
    grid-template-columns: 1fr;
  }

  .range-row strong {
    text-align: left;
  }
}
