:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #fff;
  --dock: #f4f4f4;
  --text: #111;
  --muted: #333;
  --faint: #666;
  --fainter: #888;
  --day: #999;
  --rule: #ddd;
  --input-border: #ccc;
  --error: #8a1f1f;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111;
  --dock: #1c1c1c;
  --text: #eee;
  --muted: #ccc;
  --faint: #aaa;
  --fainter: #888;
  --day: #777;
  --rule: #333;
  --input-border: #555;
  --error: #e8a0a0;
}

html {
  background: var(--bg);
}

body {
  font-family: Georgia, serif;
  max-width: 40rem;
  margin: 2rem auto;
  padding: 0 1rem 3rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

body.home-shell {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  margin: 0 auto;
  padding: 0.65rem 1rem 0.35rem;
}

.home-shell .site-head {
  flex: 0 0 auto;
  background: var(--bg);
}

.home-shell .site-head h1 {
  margin-bottom: 0.45rem;
}

.home-shell .site-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 0.6rem;
}

.home-shell .site-main.is-end {
  display: flex;
  flex-direction: column;
}

.home-shell .site-main.is-end #poem-live {
  margin-top: auto;
}

.home-shell .wall {
  margin-top: 0.4rem;
}

.home-shell .site-dock {
  flex: 0 0 auto;
  margin: 0 -1rem;
  padding: 0.7rem 1rem 0.6rem;
  border-top: 1px solid var(--rule);
  background: var(--dock);
  position: relative;
  z-index: 1;
}

.home-shell footer {
  flex: 0 0 auto;
  margin-top: 0.3rem;
  padding-top: 0.4rem;
}

.home-shell .socials {
  margin-bottom: 0.4rem;
}

.home-shell .copy {
  margin-bottom: 0.25rem;
}

h1 {
  font-weight: 400;
  font-size: 1.75rem;
  margin: 0 0 0.75rem;
}

a.home {
  color: var(--text);
  text-decoration: none;
}

a.home:hover {
  text-decoration: underline;
}

.rules {
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 2.5rem;
}

.remaining {
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.poem-tools {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 1rem;
  margin: 0 0 0.25rem;
  color: var(--faint);
}

.poem-tools a {
  color: var(--faint);
  text-decoration: none;
}

.poem-tools a:hover,
.poem-tools a:focus-visible,
.poem-tools a.is-current {
  color: var(--text);
  text-decoration: underline;
}

.jump-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.5rem;
  margin: 0;
}

.jump-form input {
  font-family: Georgia, serif;
  font-size: 1rem;
  width: 8ch;
  box-sizing: content-box;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--input-border);
  color: var(--text);
  background: var(--bg);
}

.window-links {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  margin: 1rem 0 0;
}

.window-links a {
  color: var(--faint);
  text-decoration: none;
}

.window-links a:hover,
.window-links a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

.button {
  font-family: system-ui, sans-serif;
  display: inline-block;
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
  border: 1px solid var(--text);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 1rem;
}

.button:hover,
.button:focus-visible {
  background: var(--text);
  color: var(--bg);
}

.key-form {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.45rem;
  margin: 0 0 0.5rem;
  color: var(--faint);
}

.key-form[hidden],
.next-pay[hidden],
.key-reveal[hidden],
.key-left[hidden],
.next-hint[hidden] {
  display: none !important;
}

.key-form label {
  margin: 0;
}

.key-form input {
  font-family: Georgia, serif;
  font-size: 1rem;
  width: 11ch;
  box-sizing: content-box;
  padding: 0.1rem 0.3rem;
  border: 0;
  border-bottom: 1px solid var(--input-border);
  color: var(--text);
  background: transparent;
  letter-spacing: 0.08em;
}

.key-form input:focus {
  outline: none;
  border-bottom-color: var(--text);
}

#handle,
#line {
  font-family: Georgia, serif;
  font-size: 1rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--input-border);
  color: var(--text);
  background: var(--bg);
}

.wall {
  margin: 1.5rem 0 0;
}

.line {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  column-gap: 0.75rem;
  margin: 0.6rem 0;
  scroll-margin-top: 1rem;
}

.line.is-target .num {
  color: var(--text);
}

.next-compose {
  margin: 0;
}

.next-empty .body {
  min-height: 1.5em;
}

.next-line {
  display: block;
  font-family: Georgia, serif;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0 0 0.05rem;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--input-border);
  color: var(--text);
  background: transparent;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
  caret-color: var(--text);
}

.next-line::placeholder {
  color: var(--faint);
  opacity: 1;
}

.next-line:focus {
  outline: none;
  border-bottom-color: var(--text);
}

.next-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.15rem;
  margin-top: 0.35rem;
}

.next-pay {
  font-family: Georgia, serif;
  font-size: 1rem;
  line-height: 1.3;
  padding: 0.15rem 0.7rem;
  margin: 0;
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}

.next-pay:hover,
.next-pay:focus-visible {
  background: var(--dock);
  color: var(--text);
  outline: none;
}

.key-reveal {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--faint);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.key-reveal:hover,
.key-reveal:focus-visible {
  color: var(--text);
  text-decoration: underline;
  outline: none;
}

.next-compose .key-form {
  margin: 0;
  flex-wrap: nowrap;
}

.key-left {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.handle-form input {
  width: 12ch;
  letter-spacing: 0;
}

.next-hint {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--faint);
}

.next-hint.is-error {
  color: var(--error);
}

.num {
  color: var(--fainter);
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-decoration: none;
}

.num:hover {
  color: var(--text);
}

.body {
  min-height: 1.5em;
}

.handle {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--faint);
  margin-left: 0.5rem;
  text-decoration: none;
}

a.handle:hover {
  color: var(--text);
  text-decoration: underline;
}

.by-name {
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  color: var(--faint);
  margin: -0.25rem 0 1.25rem;
}

.day {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--day);
  text-align: center;
  margin: 1.5rem 0;
}

#write-form {
  font-family: system-ui, sans-serif;
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
  padding-top: 1rem;
}

#write-form label {
  display: block;
  margin: 0.6rem 0 0.25rem;
}

#line {
  min-height: 4.5rem;
  resize: vertical;
}

.count {
  font-size: 0.8rem;
  color: var(--faint);
  margin: 0.2rem 0 0;
}

.error {
  color: var(--error);
  font-size: 0.9rem;
}

.share-card {
  font-family: Georgia, serif;
  border: 1px solid var(--rule);
  padding: 1rem 1.1rem;
  margin: 1.5rem 0 0;
}

.share-line {
  margin: 0.35rem 0;
}

.share-mine {
  margin: 0.5rem 0;
}

.share-empty {
  color: var(--faint);
}

.share-url {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--faint);
  margin: 0.9rem 0 0;
}

footer {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  color: var(--fainter);
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1rem;
}

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1.1rem;
  margin: 0 0 0.85rem;
}

.socials a {
  color: var(--fainter);
  text-decoration: none;
}

.socials a:hover,
.socials a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

.copy {
  text-align: center;
  margin: 0 0 0.5rem;
}

.footer-meta {
  text-align: center;
  margin: 0;
}

.footer-meta a,
.theme-toggle {
  color: var(--fainter);
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.footer-meta a:hover,
.theme-toggle:hover,
.footer-meta a:focus-visible,
.theme-toggle:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

a {
  color: var(--text);
}
