* {
  box-sizing: border-box;
}

:root {
  --ink: #222;
  --muted: #666;
  --paper: #fdfaf4;
  --panel: #fff;
  --line: #e4ddd0;
  --accent: #2f5d50;
  --accent-ink: #fff;
  --highlight: #fbe7a1;
  --error: #a3261b;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

.top,
main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  margin-top: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: normal;
  margin-right: 1.25rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-weight: normal;
  background: #fff;
}

input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
}

fieldset.modes {
  border: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

fieldset.modes legend {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

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

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.center {
  justify-content: center;
  margin: 1.5rem 0 3rem;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0.25rem;
  text-decoration: underline;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: normal;
}

.ok {
  color: var(--accent);
  font-weight: 600;
}

.error {
  color: var(--error);
}

/* Tabs */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  margin-bottom: -1px;
}

.tab[aria-selected="true"] {
  background: var(--panel);
  border-bottom: 1px solid var(--panel);
}

.tab-label {
  border: none;
  background: none;
  color: var(--ink);
  padding: 0.4rem 0.4rem 0.4rem 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab[aria-selected="true"] .tab-label {
  font-weight: 600;
}

.tab-close {
  border: none;
  background: none;
  color: var(--muted);
  padding: 0.4rem 0.6rem 0.4rem 0.2rem;
}

.tab-new .tab-label {
  color: var(--accent);
  padding-right: 0.75rem;
}

/* Story */

#story-meta {
  margin: 0;
}

#story,
.streaming {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.75;
}

#story h2 {
  margin-top: 2rem;
}

#story section + section {
  border-top: 1px solid var(--line);
}

.streaming {
  white-space: pre-wrap;
  color: var(--muted);
}

.w {
  cursor: pointer;
  border-radius: 3px;
}

.w:hover,
.w.active {
  background: var(--highlight);
}

/* Word dialog */

dialog {
  width: min(32rem, 92vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
}

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

.dialog-close {
  float: right;
  margin: -0.5rem -0.75rem 0 0;
  font-size: 1.1rem;
  text-decoration: none;
}

#wd-word {
  margin-bottom: 0.5rem;
}

#wd-body dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

#wd-body dt {
  font-weight: 600;
  color: var(--muted);
}

#wd-body dd {
  margin: 0;
}

.idiom {
  background: var(--paper);
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.75rem;
}
