:root {
  --bg: #eeece7;
  --paper: #f5f3ee;
  --topbar: #4f4c4c;
  --topbar-border: #605d5d;
  --text: #7a6658;
  --muted: #cfc8bf;
  --line: #dedad2;
  --white: #ffffff;
  --shadow: 0 18px 40px rgba(46, 38, 33, 0.08);
  --font-ui: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #ece8e0 0%, #e7e3db 100%);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 0 1.25rem;
  background: var(--topbar);
  color: var(--white);
  border-bottom: 1px solid var(--topbar-border);
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-group {
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  padding-right: 0.35rem;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.status-pill {
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.92rem;
  white-space: nowrap;
}

.status-group {
  gap: 0.7rem;
}

.storage-note {
  max-width: 29rem;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  line-height: 1.35;
  text-align: right;
}

.editor-shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
  background: var(--paper);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.gutter {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0)),
    var(--paper);
}

.editor-panel {
  padding: 1.1rem 1.4rem 1.4rem 1.6rem;
}

.editor {
  width: 100%;
  min-height: calc(100vh - 112px);
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(1.35rem, 1.2rem + 0.8vw, 2rem);
  line-height: 1.6;
  letter-spacing: 0.005em;
  outline: none;
}

.editor::placeholder {
  color: var(--text);
  opacity: 0.95;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: flex-start;
    padding: 0.8rem 1rem;
  }

  .status-group {
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
  }

  .status-pill {
    font-size: 0.85rem;
  }

  .storage-note {
    max-width: none;
    text-align: left;
  }

  .editor-shell {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .editor-panel {
    padding: 1rem 1rem 1.2rem 1.1rem;
  }

  .editor {
    min-height: calc(100vh - 154px);
    font-size: 1.3rem;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .gutter {
    display: none;
  }

  .editor-shell {
    display: block;
    min-height: auto;
    box-shadow: none;
    background: #ffffff;
  }

  .editor-panel {
    padding: 0;
  }

  .editor {
    min-height: auto;
    color: #222222;
    font-size: 12pt;
    line-height: 1.5;
  }
}
