:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #171717;
  --dim: #737373;
  --border: #d4d4d8;
  --card: #f4f4f5;
  --btn-bg: #f4f4f5;
  --btn-hover: #e4e4e7;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --mark-bg: #fef08a;
  --mark-text: #000000;
  --focus: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --text: #e4e4e7;
    --dim: #a1a1aa;
    --border: #27272a;
    --card: #18181b;
    --btn-bg: #27272a;
    --btn-hover: #3f3f46;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --mark-bg: #854d0e;
    --mark-text: #ffffff;
    --focus: #60a5fa;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 20px 16px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

h1 {
  font-size: 19px;
  font-weight: 600;
}

.sub {
  font-size: 12px;
  color: var(--dim);
}

.lang-select {
  padding: 3px 6px;
  font-size: 12px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
}

.error {
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid #ef4444;
  border-radius: 4px;
  color: #ef4444;
  font-size: 13px;
}

.text-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.text-lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--dim);
}

.text-actions {
  display: flex;
  gap: 6px;
}

.btn-sm {
  font-size: 12px;
  padding: 3px 8px;
  height: 26px;
}

.text-wrap {
  margin-bottom: 12px;
}

textarea,
.viewer {
  width: 100%;
  height: 200px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.viewer {
  display: none;
  position: relative;
}

::highlight(reading) {
  background-color: var(--mark-bg);
  color: var(--mark-text);
}

mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  box-shadow: 0 0 0 2px var(--mark-bg);
  border-radius: 2px;
}

.text-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--dim);
}

progress {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 5px;
  border: none;
  border-radius: 3px;
  background: var(--border);
}

progress::-webkit-progress-bar {
  background: var(--border);
  border-radius: 3px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

button:hover:not(:disabled) {
  background: var(--btn-hover);
}

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

.btn-accent {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 500;
}

.btn-accent:hover:not(:disabled) {
  opacity: 0.9;
  background: var(--accent);
}

.btn-ctrl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-text {
  font-size: 13px;
  color: var(--dim);
  margin-left: 6px;
}

.settings {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
}

.field {
  margin-bottom: 10px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--dim);
}

.voice-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-bottom: 12px;
}

.voice-grid .field {
  margin-bottom: 0;
}

.voice-row {
  display: flex;
  gap: 6px;
}

.voice-row .dropdown {
  flex: 1;
}

.voice-row button {
  height: 30px;
  padding: 4px 10px;
  white-space: nowrap;
}

.dropdown {
  position: relative;
  width: 100%;
}

.drop-box {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.drop-box input {
  width: 100%;
  height: 30px;
  padding: 4px 22px 4px 8px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  text-overflow: ellipsis;
}

.drop-caret {
  position: absolute;
  right: 8px;
  pointer-events: none;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--dim);
}

.drop-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 3px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.drop-item {
  padding: 6px 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
}

.drop-item:last-child {
  border-bottom: none;
}

.drop-item:hover,
.drop-item.active {
  background: var(--btn-hover);
}

.drop-item.selected {
  color: var(--accent);
  font-weight: 500;
}

.drop-item.empty {
  color: var(--dim);
  cursor: default;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

input[type="number"] {
  width: 64px;
  height: 28px;
  padding: 2px 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.settings-bottom {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}



.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;
}

dialog {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 18px 20px;
  width: 90%;
  max-width: 440px;
  margin: auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

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

.guide-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}

.guide-body {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.6;
  margin-bottom: 14px;
}

.guide-body p {
  margin-bottom: 6px;
}

.guide-note {
  font-size: 12px;
  color: var(--dim);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
  font-style: italic;
}

.guide-foot {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.guide-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}

.guide-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

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

@media (hover: none) {

  textarea,
  .viewer,
  .drop-box input,
  input[type="number"],
  .lang-select {
    font-size: 16px;
  }
}