:root {
  color-scheme: light;
  --background: #f3f6f5;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --text: #182624;
  --muted: #64736f;
  --border: #dce5e2;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --primary-soft: #e6f4f1;
  --danger: #b42318;
  --shadow: 0 2px 12px rgba(25, 55, 48, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 280px;
  background: var(--background);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

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

button,
select,
input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

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

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 18px;
}

.app-header h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.app-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(247, 250, 249, 0.96);
  box-shadow: 0 4px 14px rgba(25, 55, 48, 0.04);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 46px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 5px rgba(25, 55, 48, 0.1);
}

.badge {
  display: inline-block;
  min-width: 24px;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  text-align: center;
}

.card {
  margin-bottom: 14px;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
}

.stat,
.section-note {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.button {
  min-height: 46px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:active:not(:disabled) {
  transform: scale(0.985);
}

.button:focus-visible,
.tab:focus-visible,
summary:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

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

.button-primary:active:not(:disabled) {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: #28524a;
}

.button-secondary:active:not(:disabled) {
  background: var(--surface-soft);
}

.button-accent {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.button-quiet {
  flex: 0 0 auto;
  min-height: 44px;
  margin-top: -4px;
  padding-inline: 12px;
  color: var(--muted);
  font-size: 14px;
}

.button-text {
  min-height: 44px;
  padding: 6px 0 6px 12px;
  color: var(--primary);
  font-size: 13px;
  white-space: nowrap;
}

.button-full {
  width: 100%;
}

.file-controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.file-controls .button {
  flex: 1 1 auto;
}

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

select {
  min-width: 112px;
  min-height: 46px;
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

select:disabled {
  opacity: 0.55;
}

.field-help {
  margin: 9px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

textarea {
  width: 100%;
  padding: 13px;
  border: 1px solid #cbd9d5;
  border-radius: 12px;
  background: #fbfdfc;
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
  caret-color: var(--primary);
}

textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

textarea::placeholder {
  color: #8a9995;
}

.source-text {
  height: clamp(240px, 38dvh, 500px);
  resize: vertical;
}

.result-text {
  height: clamp(300px, 52dvh, 620px);
  resize: vertical;
  background: var(--surface-soft);
}

.selection-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
}

.selection-info {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.selection-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 8px;
}

.selection-actions .button {
  min-width: 0;
  padding-inline: 7px;
  font-size: 13px;
}

.range-points {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.range-point {
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.range-point span,
.range-point strong {
  display: block;
}

.range-point span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.range-point strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}

.field-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.option-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.check-option {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  color: #38524c;
  font-size: 13px;
  cursor: pointer;
}

.check-option input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
}

.marker-details {
  margin: 11px -4px -4px;
  border-top: 1px solid var(--border);
}

.marker-details summary {
  min-height: 48px;
  padding: 14px 4px 10px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.marker-content {
  padding: 2px 4px 4px;
}

.marker-block {
  margin-bottom: 14px;
}

.marker-block > label {
  display: block;
  margin-bottom: 6px;
  color: #38524c;
  font-size: 13px;
  font-weight: 650;
}

.marker-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  align-items: stretch;
  gap: 8px;
}

.marker-input-row textarea {
  min-height: 72px;
  resize: vertical;
}

.occurrence-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}

.occurrence-label input {
  width: 38px;
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.privacy-note {
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.empty-state {
  padding: 42px 0 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state p {
  margin: 0 0 18px;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.action-dock {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(220, 229, 226, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -5px 20px rgba(25, 55, 48, 0.06);
  backdrop-filter: blur(14px);
}

.dock-content {
  max-width: 732px;
  margin: 0 auto;
}

.dock-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
}

.notice {
  position: fixed;
  right: 14px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
  padding: 10px 12px 10px 15px;
  border: 1px solid #b9d9d2;
  border-radius: 13px;
  background: #effaf7;
  color: #155e54;
  box-shadow: 0 8px 28px rgba(25, 55, 48, 0.16);
  font-size: 14px;
}

.notice.error {
  border-color: #ecc5c0;
  background: #fff5f3;
  color: #8f251c;
}

.notice button {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.noscript-message {
  position: fixed;
  inset: 20px;
  z-index: 50;
  padding: 20px;
  background: #fff5f3;
  color: #8f251c;
}

.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: 359px) {
  .app-shell {
    padding-inline: 10px;
  }

  .card {
    padding: 14px;
  }

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

  .selection-actions .button-accent {
    grid-column: 1 / -1;
  }

  .file-controls {
    flex-wrap: wrap;
  }

  .file-controls .button {
    flex-basis: 100%;
  }
}

@media (min-width: 640px) {
  .app-shell {
    padding: 28px 24px 110px;
  }

  .app-header h1 {
    font-size: 30px;
  }

  .card {
    padding: 22px;
  }

  .source-text {
    height: 400px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}
