:root {
  --paper: #EEF2E9;
  --rule: #C7D6BC;
  --ink: #232620;
  --muted: #6B7263;
  --accent: #B4432B;

  --line-height: 30px;
  --font-mono: "JetBrains Mono", "SF Mono", "Consolas", "Menlo", ui-monospace, monospace;
  --font-sans: -apple-system, "Hiragino Sans", "Yu Gothic", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  overflow: hidden;
}

/* ---------- ヘッダー ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: clamp(10px, 3vw, 20px);
  padding: max(12px, env(safe-area-inset-top)) clamp(14px, 4vw, 28px) 10px;
  flex-shrink: 0;
}

.bar__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.bar__status {
  margin: 0;
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 1em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar__actions {
  display: flex;
  gap: 4px;
}

.bar__btn {
  appearance: none;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.bar__btn:hover {
  color: var(--ink);
  background: rgba(35, 38, 32, 0.06);
}

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

.bar__btn.is-armed {
  color: var(--accent);
}

/* ---------- 本文エリア(方眼罫のパッド) ---------- */

.pad {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 0 clamp(10px, 3vw, 24px);
}

.pad__textarea {
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  outline: none;
  background:
    linear-gradient(to right, transparent 0 44px, var(--accent) 44px 46px, transparent 46px 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--line-height) - 1px),
      var(--rule) calc(var(--line-height) - 1px),
      var(--rule) var(--line-height)
    );
  background-attachment: local;
  padding: 4px 12px 24px 58px;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: var(--line-height);
  color: var(--ink);
  caret-color: var(--accent);
}

.pad__textarea::placeholder {
  color: var(--muted);
  opacity: 0.65;
}

/* ---------- フッター ---------- */

.foot {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 8px clamp(14px, 4vw, 28px) max(10px, env(safe-area-inset-bottom));
}

.foot__count {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ---------- アクセシビリティ ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 420px) {
  .bar__title {
    display: none;
  }
}
