:root {
  color-scheme: light;
  --paper: #e7dcc8;
  --ink: #241c16;
  --muted: #5e564e;
  --line: rgba(70, 48, 28, 0.16);
  --card: rgba(255, 252, 247, 0.92);
  --seal: #9d342c;
  --seal-ink: #fff8f3;
  --focus: #245c45;
  --danger: #8d2b24;
}

* {
  box-sizing: border-box;
}

html {
  background-color: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

.page {
  width: min(740px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 72px;
}

.masthead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.masthead-text {
  flex: 1;
  min-width: 12rem;
}

.masthead-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.social {
  display: flex;
  align-items: center;
  gap: 8px;
}

.social a {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 252, 247, 0.72);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.social a:active {
  color: var(--seal);
  border-color: var(--seal);
}

@media (hover: hover) and (pointer: fine) {
  .social a:hover {
    color: var(--seal);
    border-color: var(--seal);
  }
}

.social a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.social svg {
  width: 16px;
  height: 16px;
  display: block;
}

.social .mark {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Iowan Old Style", serif;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  line-height: 1;
}

.logout {
  margin: 0;
}

.logout button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.seal {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  margin: 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--seal);
  color: var(--seal);
  border-radius: 4px;
  transform: rotate(-8deg);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Iowan Old Style", serif;
  font-size: 24px;
  line-height: 1;
}

h1,
h2,
h3,
.word {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Iowan Old Style", serif;
  font-weight: 500;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.lead,
.section-note,
footer {
  color: var(--muted);
}

.lead {
  margin: 6px 0 0;
  font-size: 0.95rem;
}

.lead span {
  white-space: nowrap;
}

.block + .block {
  margin-top: 28px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 20px 16px;
  box-shadow: 0 16px 40px rgba(68, 40, 16, 0.05);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0;
  font-size: 0.85rem;
}

.order {
  display: inline-flex;
  gap: 4px;
}

.order button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
}

.order button[aria-pressed="true"] {
  border-color: var(--line);
  background: rgba(255, 252, 247, 0.8);
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

label {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  color: inherit;
  font: inherit;
  padding: 12px 12px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.75;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

input[readonly] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.28);
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

button {
  appearance: none;
  border: 0;
  background: var(--seal);
  color: var(--seal-ink);
  font: inherit;
  letter-spacing: 0.06em;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 20px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.status {
  margin: 0;
  min-height: 1.5em;
  color: var(--focus);
  font-size: 0.92rem;
}

.status.loading,
.loading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading {
  justify-content: center;
  margin: 0;
  padding: 28px 16px;
  color: var(--muted);
}

.status.loading::before,
.loading::before {
  content: "";
  width: 0.9em;
  height: 0.9em;
  border: 2px solid var(--line);
  border-top-color: var(--seal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .status.loading::before,
  .loading::before {
    animation: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.field-error {
  margin: 0;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

#list {
  display: grid;
  gap: 12px;
}

.quote {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px 16px 20px;
}

.quote::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 3px;
  background: var(--seal);
}

.quote-top {
  display: grid;
  gap: 4px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.word {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

time {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.content {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.45);
}

.empty p {
  margin: 0;
}

.empty button {
  margin-top: 12px;
}

#list-status:empty {
  display: none;
}

.more {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  min-height: 1.5em;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.more[hidden] {
  display: none;
}

.quote-edit {
  margin-top: 12px;
}

.quote-edit textarea {
  min-height: 96px;
}

.quote-actions,
.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.quote-actions button,
.edit-actions button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
}

.quote-actions button.danger-text {
  color: var(--danger);
}

button.danger {
  background: var(--danger);
}

.confirm {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36, 28, 22, 0.4);
}

.confirm[hidden] {
  display: none;
}

.confirm-card {
  width: min(420px, 100%);
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 16px;
  box-shadow: 0 16px 40px rgba(68, 40, 16, 0.16);
}

.confirm-card p {
  margin: 0;
}

#confirm-title {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Iowan Old Style", serif;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
}

.confirm-word {
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.confirm-actions button {
  min-height: 40px;
  padding: 0 16px;
}

footer {
  margin-top: 36px;
  font-size: 0.8rem;
}

footer p {
  margin: 0;
}

@media (max-width: 640px) {
  .page {
    width: min(740px, calc(100% - 24px));
    padding-top: 28px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  #form button[type="submit"] {
    width: 100%;
  }

  time {
    white-space: normal;
  }
}
