:root {
  --paper: #f6f3ed;
  --surface: #fffdfa;
  --ink: #20201e;
  --muted: #77736b;
  --line: #dcd7ce;
  --orange: #ef6a37;
  --orange-soft: #fff0e8;
  --danger: #c84936;
  --danger-soft: #fff0ed;
  --placeholder: #b9b4ab;
  --switch-off: #c8c3ba;
  --footer: #9d978e;
  --button-bg: #20201e;
  --button-text: #fffdfa;
  --button-hover-text: #20201e;
  color-scheme: light;
  font-family: "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --paper: #171715;
  --surface: #22221f;
  --ink: #f2efe8;
  --muted: #aaa59b;
  --line: #3b3a35;
  --orange: #ff8150;
  --orange-soft: #35251e;
  --danger: #ff8d7c;
  --danger-soft: #38231f;
  --placeholder: #77736b;
  --switch-off: #5a5851;
  --footer: #77736b;
  --button-bg: #f2efe8;
  --button-text: #171715;
  --button-hover-text: #171715;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --paper: #171715;
    --surface: #22221f;
    --ink: #f2efe8;
    --muted: #aaa59b;
    --line: #3b3a35;
    --orange: #ff8150;
    --orange-soft: #35251e;
    --danger: #ff8d7c;
    --danger-soft: #38231f;
    --placeholder: #77736b;
    --switch-off: #5a5851;
    --footer: #77736b;
    --button-bg: #f2efe8;
    --button-text: #171715;
    --button-hover-text: #171715;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--paper);
  font-family: serif;
  font-size: 18px;
  background: var(--ink);
  border-radius: 50%;
}

.privacy-note {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  gap: 18px;
  align-items: center;
}

.theme-toggle {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--muted);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.theme-icon {
  display: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

:root:not([data-theme]) .theme-icon-system,
:root[data-theme="light"] .theme-icon-light,
:root[data-theme="dark"] .theme-icon-dark {
  display: block;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #4eaa73;
  border-radius: 50%;
}

.counter-app {
  max-width: 980px;
  margin: 64px auto 0;
}

.page-title {
  margin: 0 0 18px;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.4;
  letter-spacing: -0.02em;
}

.primary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.primary-stat {
  display: flex;
  min-height: 108px;
  padding: 23px 32px;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.primary-stat:last-child {
  border-right: 0;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-value {
  margin-top: 4px;
  font-family: "DM Mono", monospace;
  font-size: 38px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.accent-stat {
  background: var(--orange-soft);
}

.accent-stat .stat-value {
  color: var(--orange);
}

.editor-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.editor-label {
  font-size: 12px;
  font-weight: 600;
}

.toolbar-actions {
  display: flex;
  gap: 3px;
}

.text-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 11px;
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
  background: var(--paper);
}

.text-button.danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.text-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

textarea {
  display: block;
  width: 100%;
  min-height: 330px;
  padding: 32px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.95;
  resize: vertical;
  background: var(--surface);
  border: 0;
  outline: none;
  caret-color: var(--orange);
}

textarea::placeholder {
  color: var(--placeholder);
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  padding: 0 22px;
  color: var(--muted);
  font-size: 10px;
  border-top: 1px solid var(--line);
}

.save-control {
  display: flex;
  gap: 10px;
  align-items: center;
}

.save-switch {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

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

.switch-track {
  position: relative;
  width: 30px;
  height: 17px;
  background: var(--switch-off);
  border-radius: 999px;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  background: var(--surface);
  border-radius: 50%;
}

.save-switch input:checked + .switch-track {
  background: var(--orange);
}

.save-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(13px);
}

.save-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

#save-status {
  color: var(--muted);
}

.limit-control {
  display: flex;
  gap: 9px;
  align-items: center;
}

.limit-control input {
  width: 92px;
  padding: 6px 8px;
  color: var(--ink);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  text-align: right;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
}

.limit-control input:focus {
  border-color: var(--orange);
}

.limit-control input::placeholder {
  color: #aaa59c;
}

.limit-progress {
  height: 3px;
  background: var(--line);
}

.limit-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--orange);
}

.limit-progress.over span {
  background: var(--danger);
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.detail-stat {
  display: flex;
  min-height: 82px;
  padding: 17px 20px;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.detail-stat:last-child {
  border-right: 0;
}

.detail-stat > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.detail-stat strong {
  margin-top: 5px;
  font-family: "DM Mono", monospace;
  font-size: 22px;
  font-weight: 500;
}

.detail-stat small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.reading-time-note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  text-align: right;
}

.feature-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  margin: 105px 0 40px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.feature-strip > div {
  padding: 36px 38px 40px;
  border-right: 1px solid var(--line);
}

.feature-strip > div:last-child {
  border-right: 0;
}

.feature-number {
  color: var(--orange);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.feature-strip h2 {
  margin: 14px 0 10px;
  font-size: 16px;
}

.feature-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 40px;
  color: var(--footer);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.repository-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 90px;
  padding: 30px 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.repository-eyebrow {
  color: var(--orange);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
}

.repository-card h2 {
  margin: 8px 0 5px;
  font-size: 18px;
}

.repository-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.repository-link {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  color: var(--button-text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--button-bg);
  border: 1px solid var(--button-bg);
  border-radius: 9px;
}

.repository-link:hover {
  color: var(--button-hover-text);
  background: var(--orange);
  border-color: var(--orange);
}

.repository-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  padding: 10px 16px;
  color: var(--button-text);
  font-size: 12px;
  pointer-events: none;
  background: var(--button-bg);
  border-radius: 8px;
  visibility: hidden;
  transform: translateX(-50%);
}

.toast.visible {
  visibility: visible;
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 28px, 600px);
  }

  .site-header {
    min-height: 72px;
  }

  .privacy-note {
    font-size: 0;
  }

  .privacy-note::after {
    content: "端末内で処理";
    font-size: 10px;
  }

  .header-actions {
    gap: 10px;
  }

  .theme-toggle {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .theme-toggle span {
    display: none;
  }

  .counter-app {
    margin-top: 38px;
  }

  .primary-stat {
    min-height: 88px;
    padding: 18px;
  }

  .stat-value {
    font-size: 30px;
  }

  textarea {
    min-height: 310px;
    padding: 24px 20px;
    font-size: 16px;
  }

  .editor-label {
    display: none;
  }

  .editor-toolbar {
    justify-content: flex-end;
    padding: 0 10px;
  }

  .detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-stat {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .detail-stat:nth-child(2n) {
    border-right: 0;
  }

  .detail-stat:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .reading-time-note {
    text-align: left;
  }

  .feature-strip {
    grid-template-columns: 1fr;
    margin: 75px 0 28px;
  }

  .feature-strip > div {
    padding: 27px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .feature-strip > div:last-child {
    border-bottom: 0;
  }

  .repository-card {
    gap: 22px;
    align-items: stretch;
    margin-bottom: 55px;
    padding: 25px;
    flex-direction: column;
  }

  .repository-link {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .primary-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .primary-stat {
    border-bottom: 1px solid var(--line);
  }

  .primary-stat:nth-child(2) {
    border-right: 0;
  }

  .primary-stat:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .editor-footer {
    gap: 12px;
    align-items: flex-start;
    padding: 13px 16px;
    flex-direction: column;
  }

  .save-control {
    width: 100%;
    justify-content: space-between;
  }
}
