:root {
  color-scheme: light;
  --paper: #f4efe6;
  --ink: #1c1915;
  --faint: #6e675c;
  --rule: #ddd4c4;
  --accent: #8c2f2f;
  --selected: #efe2c9;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 21px/1.55 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 28px 0;
}
.brand { margin: 0; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase; font-family: "Segoe UI", sans-serif; }
.tag { margin: 6px 0 0; color: var(--faint); font-size: 16px; }
.days { display: flex; gap: 10px; align-items: center; font-family: "Segoe UI", sans-serif; font-size: 14px; }
.days button, #close, #send, #find {
  font: 14px/1 "Segoe UI", sans-serif;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}
.days button { background: var(--paper); }
.brand { cursor: pointer; }
#sheet { padding: 16px 28px 120px; }
#opened {
  width: min(8.5in, 100%);
  margin: 0 auto 12px;
  font: 14px/1 "Segoe UI", sans-serif;
  color: var(--faint);
}
.howto {
  max-width: 760px;
  margin: 8px auto 0;
  padding: 0 28px;
  font-family: "Segoe UI", sans-serif;
}
body.shelf .howto { display: none; }
#how {
  border: 0;
  background: transparent;
  padding: 0;
  font: 16px/1.4 "Segoe UI", sans-serif;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#rules {
  margin: 14px 0 0;
  font-size: 15px;
  line-height: 1.5;
}
#rules p { margin: 0 0 8px; }
#rules ul { margin: 0; padding-left: 1.2em; }
#rules li + li { margin-top: 6px; }
#pages { margin-top: 6px; }
.page {
  width: min(8.5in, 100%);
  min-height: 11in;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d9d3c7;
  padding: 1in 1.35in;
}
.page + .page { margin-top: 0.4in; }
body.shelf { background: var(--paper); }
body.shelf #sheet { display: none; }
#shelf { display: none; padding: 36px 24px 80px; }
body.shelf #shelf { display: block; }
#shelf h1 {
  margin: 8px 0 48px;
  text-align: center;
  font: 18px/1.4 "Segoe UI", sans-serif;
  font-weight: 400;
}
#files {
  display: grid;
  grid-template-columns: repeat(5, 128px);
  justify-content: center;
  gap: 36px 42px;
  max-width: 920px;
  margin: 0 auto;
}
.file {
  position: relative;
  width: 128px;
  height: 164px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.file svg { display: block; width: 128px; height: 164px; }
.file-date {
  position: absolute;
  left: 10px;
  bottom: 14px;
  font: 16px/1 "Segoe UI", sans-serif;
  color: #5c4630;
}
.shelf-empty {
  grid-column: 1 / -1;
  margin: 0;
  text-align: center;
  font: 16px/1.4 "Segoe UI", sans-serif;
  color: var(--faint);
}
.essay {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.blank { color: var(--faint); }
.type-slot {
  display: inline-block;
  width: 1.7em;
  height: 1.15em;
  margin: 0 0.12em;
  vertical-align: -0.12em;
  background: #f6d5d5;
  border: 1px solid #e4b0b0;
  padding: 0;
  cursor: pointer;
}
.type-slot:hover { background: #f0c4c4; }
dialog {
  width: min(720px, calc(100vw - 32px));
  height: min(82vh, 760px);
  border: 1px solid var(--ink);
  padding: 0;
  background: #fbf7f0;
  color: var(--ink);
}
dialog[open] {
  display: flex;
  flex-direction: column;
}
dialog::backdrop { background: rgba(28, 25, 21, 0.45); }
.dlg-head, #compose {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  font-family: "Segoe UI", sans-serif;
}
.clocks { display: flex; gap: 28px; align-items: baseline; font-size: 16px; }
.clock-item strong { margin-left: 8px; font-variant-numeric: tabular-nums; }
.clock-item.closed { color: var(--faint); }
.search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  padding: 0 16px;
}
#search, #entry {
  font: 18px/1.4 Georgia, serif;
  border: 1px solid var(--ink);
  background: #fff;
  color: inherit;
  padding: 0 10px;
  height: 44px;
}
#find, #send {
  height: 44px;
  padding: 0 12px;
}
#search { flex: 1; min-width: 0; }
#list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  flex: 1;
  min-height: 0;
  margin: 12px 16px;
  padding: 10px;
  border: 1px solid #9a948a;
  background: transparent;
  overflow: auto;
}
#list li {
  flex: 1 1 calc((100% - 40px) / 6);
  min-width: max(calc((100% - 40px) / 6), min(100%, max-content));
  max-width: 100%;
  padding: 0;
}
#list button.word {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--ink);
  background: transparent;
  color: inherit;
  font: 18px/1.3 Georgia, serif;
  cursor: pointer;
  text-align: center;
}
#list button.word:hover:not(:disabled) { background: var(--selected); }
#list li.selected button.word { background: #f6d5d5; }
#list li .star { color: var(--accent); }
#list li.mine .tag { font-family: "Segoe UI", sans-serif; font-size: 13px; color: var(--faint); }
#compose {
  align-items: stretch;
  padding: 0 16px 12px;
  background: transparent;
}
#entry { flex: 1; }
#entry:disabled {
  color: var(--faint);
  background: #e4dfd6;
  border-color: #c9c3b8;
}
#note {
  margin: -6px 16px 12px;
  min-height: 18px;
  font: 13px/1.3 "Segoe UI", sans-serif;
  color: var(--accent);
}
#note.phase { color: var(--faint); }
@media (max-width: 860px) {
  #files { grid-template-columns: repeat(3, 120px); }
}
@media (max-width: 640px) {
  body { font-size: 19px; }
  .top { flex-direction: column; align-items: start; }
  #files { grid-template-columns: repeat(2, 120px); }
  .page { padding: 0.7in 0.7in; }
  #list li {
    flex-basis: calc((100% - 24px) / 4);
    min-width: max(calc((100% - 24px) / 4), min(100%, max-content));
  }
}
