:root {
  --guestbook-bg: #f5f0e8;
  --guestbook-card: rgba(255, 254, 249, 0.65);
  --guestbook-border: #d4c8b0;
  --guestbook-text: #3d3226;
  --guestbook-soft: #5f5146;
  --guestbook-dim: #8b7d6b;
  --guestbook-accent: #8b2500;
  --guestbook-accent-light: #c75b3a;
  --guestbook-tile: #faf7f0;
  --guestbook-hover: #f0e6d2;
  --guestbook-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
}

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

html {
  min-height: 100%;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding: 2.3rem 0.8rem;
  color: var(--guestbook-text);
  font-family: "PingFang SC", "Noto Serif SC", "Source Han Serif SC", "Hiragino Mincho Pro", "Songti SC", serif;
  background: radial-gradient(
    ellipse at 50% 30%,
    #faf6ec 0%,
    #efe8d6 60%,
    #e0d8c0 100%
  );
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--guestbook-accent);
}

.guestbook-page {
  position: relative;
  z-index: 1;
  width: min(100%, 1320px);
  margin: 0 auto;
}

.guestbook-header,
.guestbook-layout {
  width: 100%;
}

.guestbook-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.guestbook-heading {
  min-width: 0;
}

.guestbook-heading p {
  color: var(--guestbook-dim);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-intro {
  color: var(--guestbook-dim);
  font-size: 0.86rem;
  line-height: 1.6;
}

.guestbook-layout {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  align-items: start;
  column-gap: 0.8rem;
  row-gap: 0.68rem;
}

.guestbook-card {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--guestbook-border);
  border-radius: 8px;
  background: var(--guestbook-card);
  box-shadow: var(--guestbook-shadow);
}

.wall-card {
  display: flex;
  flex-direction: column;
  max-height: 754px;
  min-height: 0;
  overflow: hidden;
}

.compose-card {
  position: sticky;
  top: 1rem;
}

.guestbook-card h2 {
  color: var(--guestbook-soft);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.compose-card .section-intro {
  margin: 0.4rem 0 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.8rem;
}

.form-field label {
  color: var(--guestbook-soft);
  font-size: 0.9rem;
  font-weight: 600;
}

.form-field label span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.form-field input,
.form-field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1.5px solid var(--guestbook-border);
  border-radius: 6px;
  outline: none;
  padding: 0.4rem 0.55rem;
  color: var(--guestbook-text);
  background: var(--guestbook-tile);
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--guestbook-accent-light);
}

.form-field textarea {
  min-height: 8rem;
  line-height: 1.6;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.char-count {
  color: var(--guestbook-dim);
  font-size: 0.78rem;
}

.submit-button {
  border: none;
  border-radius: 6px;
  padding: 0.42rem 1rem;
  color: #fff;
  background: var(--guestbook-accent);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.load-more {
  width: 100%;
  border: 0;
  border-top: 1px dotted var(--guestbook-border);
  border-radius: 0;
  padding: 0.55rem 0 0.25rem;
  color: var(--guestbook-dim);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 400;
}

.submit-button:hover:not(:disabled) {
  background: #7a1f00;
}

.submit-button:disabled,
.load-more:disabled {
  cursor: default;
  opacity: 0.55;
}

.form-status,
.wall-status {
  min-height: 1.4rem;
  margin-top: 0.55rem;
  color: var(--guestbook-dim);
  font-size: 0.82rem;
  line-height: 1.5;
}

.form-status:empty,
.wall-status:empty {
  min-height: 0;
  margin-top: 0;
}

.form-status.is-success,
.wall-status.is-success,
.reply-status.is-success {
  color: #477248;
}

.form-status.is-error,
.wall-status.is-error,
.reply-status.is-error {
  color: #a12828;
}

.entry-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.entry-list {
  display: grid;
  gap: 0;
}

.guestbook-entry {
  padding: 0.75rem 0;
  border-bottom: 1px dotted rgba(212, 200, 176, 0.85);
}

.guestbook-entry:first-child {
  padding-top: 0.35rem;
}

.guestbook-entry:last-child {
  padding-bottom: 0.35rem;
  border-bottom: 0;
}

.entry-line {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: start;
  column-gap: 0;
}

.entry-nickname,
.entry-separator,
.entry-content {
  font-size: 0.92rem;
  line-height: 1.68;
}

.entry-nickname {
  color: var(--guestbook-accent);
  font-weight: 700;
  white-space: nowrap;
}

.entry-separator {
  color: var(--guestbook-dim);
}

.entry-content {
  min-width: 0;
  margin: 0;
  color: var(--guestbook-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry-time {
  flex-shrink: 0;
  margin-left: 0.7rem;
  color: var(--guestbook-dim);
  font-size: 0.74rem;
  line-height: 1.68;
  white-space: nowrap;
}

.entry-actions {
  display: flex;
  align-items: flex-start;
  margin-left: 0.7rem;
  line-height: 1.68;
  white-space: nowrap;
}

.reply-toggle {
  display: block;
  border: 0;
  padding: 0;
  color: var(--guestbook-accent);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1.68;
}

.reply-toggle:hover {
  color: var(--guestbook-accent-light);
}

.reply-thread {
  margin: 0.35rem 0 0 0.9rem;
  padding-left: 0.7rem;
  border-left: 1px dotted var(--guestbook-border);
}

.reply-thread[hidden] {
  display: none;
}

.reply-list {
  display: grid;
  gap: 0.2rem;
  margin-bottom: 0.45rem;
}

.reply-item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: start;
  color: var(--guestbook-dim);
  font-size: 0.82rem;
  line-height: 1.55;
}

.reply-nickname {
  color: var(--guestbook-accent);
  font-weight: 700;
  white-space: nowrap;
}

.reply-content {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.reply-time {
  margin-left: 0.7rem;
  color: var(--guestbook-dim);
  font-size: 0.7rem;
  white-space: nowrap;
}

.reply-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.4rem;
}

.reply-form-fields {
  display: grid;
  gap: 0.3rem;
}

.reply-form input,
.reply-form textarea {
  width: 100%;
  border: 1px solid var(--guestbook-border);
  border-radius: 5px;
  padding: 0.28rem 0.45rem;
  color: var(--guestbook-text);
  background: var(--guestbook-tile);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}

.reply-form textarea {
  min-height: 2.4rem;
  resize: vertical;
}

.reply-form input:focus,
.reply-form textarea:focus {
  border-color: var(--guestbook-accent-light);
}

.reply-submit {
  border: 0;
  border-radius: 5px;
  padding: 0.3rem 0.65rem;
  color: #fff;
  background: var(--guestbook-accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.reply-submit:disabled {
  cursor: default;
  opacity: 0.55;
}

.reply-status {
  min-height: 1.2rem;
  margin-top: 0.3rem;
  color: var(--guestbook-dim);
  font-size: 0.78rem;
  line-height: 1.5;
}

.reply-status:empty {
  min-height: 0;
  margin-top: 0;
}

.empty-state {
  padding: 2.4rem 1rem;
  color: var(--guestbook-dim);
  font-size: 0.9rem;
  text-align: center;
}

.load-more:not([hidden]) {
  display: block;
  margin: 0.35rem 0 0;
}

.load-more:hover:not(:disabled) {
  color: var(--guestbook-accent);
  background: transparent;
}

@media (max-width: 860px) {
  body {
    padding: 1.4rem 0.7rem;
  }

  .guestbook-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.7rem;
  }

  .guestbook-layout {
    grid-template-columns: 1fr;
  }

  .compose-card {
    position: static;
  }

  .guestbook-card {
    padding: 0.7rem;
  }

  .wall-card {
    display: block;
    height: auto !important;
    max-height: none !important;
    overflow: visible;
  }

  .entry-scroll {
    overflow: visible;
    padding-right: 0;
  }
}
