:root {
  color-scheme: light;
  --navy: #15233d;
  --navy-2: #213657;
  --ink: #1d2839;
  --muted: #687286;
  --paper: #f7f6f1;
  --white: #fff;
  --lime: #cce95a;
  --lime-soft: #eff7c9;
  --cyan: #8de2dc;
  --line: #d7dce3;
  --danger: #a4343c;
  --sans: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid #007b8a;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 15px;
  transform: translateY(-150%);
  background: #fff;
  color: #000;
}

.skip-link:focus {
  transform: none;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  min-height: 76px;
  padding: 10px 24px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid rgb(255 255 255 / 25%);
  background: var(--navy);
  color: #fff;
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--lime);
  color: var(--lime);
  font-family: var(--serif);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.brand small {
  color: rgb(255 255 255 / 62%);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgb(255 255 255 / 72%);
  font-size: 0.76rem;
}

.save-state__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
}

.portfolio-back {
  justify-self: end;
  color: #fff;
  font-size: 0.82rem;
  text-underline-offset: 0.25em;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 76px);
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 0.75fr);
}

.editor-panel {
  position: sticky;
  top: 76px;
  display: flex;
  height: calc(100vh - 76px);
  min-height: 650px;
  padding: clamp(24px, 4vw, 56px);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.panel-heading,
.block-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.panel-heading h1,
.block-heading h2 {
  margin: 0;
}

.panel-heading h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.toolbar button,
.icon-button,
.text-button {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.toolbar__danger,
.text-button--danger {
  color: var(--danger) !important;
}

.title-field {
  display: grid;
  margin-top: 32px;
  grid-template-columns: 8em 1fr;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.title-field input {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
}

.editor-label {
  display: block;
  min-height: 0;
  margin-top: 20px;
  flex: 1;
}

.editor-label textarea {
  width: 100%;
  height: 100%;
  min-height: 360px;
  padding: 28px;
  resize: none;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--white), var(--white)) padding-box,
    repeating-linear-gradient(0deg, transparent, transparent 33px, #eef0f3 34px) border-box;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 1.3vw, 1.12rem);
  line-height: 2;
}

.editor-label textarea:focus {
  border-color: var(--navy);
  outline: 3px solid rgb(0 123 138 / 22%);
}

.editor-footer {
  display: flex;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 20px;
  color: var(--muted);
  font-size: 0.73rem;
}

.analysis-panel {
  min-width: 0;
  background: var(--paper);
}

.analysis-block {
  padding: 34px clamp(22px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
}

.analysis-block--summary {
  background: var(--navy);
  color: #fff;
}

.analysis-block--summary .eyebrow,
.analysis-block--summary .block-heading span {
  color: rgb(255 255 255 / 58%);
}

.block-heading h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.icon-button {
  border-color: rgb(255 255 255 / 34%);
  background: transparent;
  color: #fff;
}

.settings-panel {
  display: grid;
  margin-top: 22px;
  padding: 18px;
  gap: 12px;
  background: var(--navy-2);
}

.settings-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: rgb(255 255 255 / 74%);
  font-size: 0.78rem;
}

.settings-panel input {
  width: 76px;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid rgb(255 255 255 / 34%);
  background: var(--navy);
  color: #fff;
}

.metric-grid {
  display: grid;
  margin: 28px 0 0;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgb(255 255 255 / 24%);
  border-left: 1px solid rgb(255 255 255 / 24%);
}

.metric {
  min-height: 112px;
  padding: 15px;
  border-right: 1px solid rgb(255 255 255 / 24%);
  border-bottom: 1px solid rgb(255 255 255 / 24%);
}

.metric dt {
  color: rgb(255 255 255 / 58%);
  font-size: 0.72rem;
}

.metric dd {
  display: flex;
  margin: 11px 0 0;
  align-items: baseline;
  gap: 4px;
}

.metric strong {
  color: var(--lime);
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}

.metric--primary strong {
  font-size: 2.3rem;
}

.metric dd span {
  color: rgb(255 255 255 / 60%);
  font-size: 0.7rem;
}

.time-grid {
  display: grid;
  margin-top: 16px;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.time-grid div {
  padding: 14px;
  background: var(--navy-2);
}

.time-grid span,
.time-grid strong {
  display: block;
}

.time-grid span {
  color: rgb(255 255 255 / 56%);
  font-size: 0.7rem;
}

.time-grid strong {
  margin-top: 4px;
  color: var(--cyan);
}

.goal-controls {
  display: grid;
  margin-top: 22px;
  grid-template-columns: 1fr 130px;
  gap: 10px;
}

.goal-controls label {
  color: var(--muted);
  font-size: 0.72rem;
}

.goal-controls select,
.goal-controls input {
  width: 100%;
  min-height: 46px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.goal-progress {
  width: 100%;
  height: 14px;
  margin-top: 20px;
  border: 0;
  border-radius: 0;
  background: #dfe3e7;
}

.goal-progress::-webkit-progress-bar {
  background: #dfe3e7;
}

.goal-progress::-webkit-progress-value {
  background: var(--navy);
}

.goal-progress::-moz-progress-bar {
  background: var(--navy);
}

.goal-copy,
.block-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.finding-count {
  min-width: 54px;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: right;
}

.finding-count strong {
  color: var(--danger);
  font-size: 1.2rem;
}

.finding-list,
.word-list,
.history-list {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.finding-list li {
  display: grid;
  padding: 15px 0;
  grid-template-columns: auto 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.finding-list strong {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: #f4dfdf;
  color: var(--danger);
  font-size: 0.75rem;
}

.finding-list span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.finding-list b {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
}

.word-list li {
  display: grid;
  padding: 9px 0;
  grid-template-columns: 2em minmax(6em, 1fr) 1.8fr 3em;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.word-list strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.word-list progress {
  width: 100%;
  height: 8px;
  border: 0;
  background: #dfe3e7;
}

.word-list progress::-webkit-progress-bar {
  background: #dfe3e7;
}

.word-list progress::-webkit-progress-value {
  background: var(--cyan);
}

.word-list progress::-moz-progress-bar {
  background: var(--cyan);
}

.text-button {
  min-height: 38px;
  border: 0;
  background: transparent;
}

.history-list li {
  display: grid;
  padding: 14px 0;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.history-list button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.history-list strong,
.history-list small {
  display: block;
}

.history-list small {
  color: var(--muted);
}

.history-list .history-delete {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  color: var(--danger);
  text-align: center;
}

.empty-state {
  display: block !important;
  padding: 18px 0 !important;
  color: var(--muted);
  font-size: 0.82rem;
}

.privacy-note {
  margin: 34px;
  padding: 24px;
  border: 1px solid var(--navy);
  background: var(--lime-soft);
}

.privacy-note h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
}

.privacy-note p {
  color: #475239;
  font-size: 0.76rem;
}

.privacy-note button,
.danger-button {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
}

.confirm-dialog {
  width: min(100% - 40px, 480px);
  padding: 0;
  border: 1px solid var(--navy);
}

.confirm-dialog::backdrop {
  background: rgb(21 35 61 / 58%);
}

.confirm-dialog form {
  padding: 28px;
}

.confirm-dialog h2 {
  margin: 0;
  font-family: var(--serif);
}

.confirm-dialog form > div {
  display: flex;
  margin-top: 24px;
  justify-content: flex-end;
  gap: 10px;
}

.confirm-dialog button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  background: #fff;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 13px 18px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 12px 30px rgb(21 35 61 / 24%);
}

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

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr auto;
  }

  .save-state {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: relative;
    top: auto;
    height: auto;
    min-height: 700px;
    border-right: 0;
  }
}

@media (max-width: 620px) {
  .app-header {
    min-height: 68px;
    padding-inline: 16px;
  }

  .brand small,
  .portfolio-back span {
    display: none;
  }

  .portfolio-back {
    font-size: 0.73rem;
  }

  .editor-panel {
    min-height: calc(100vh - 68px);
    padding: 24px 18px;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .toolbar button {
    flex: 1 1 calc(50% - 6px);
  }

  .title-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .editor-label textarea {
    min-height: 430px;
    padding: 20px;
    resize: vertical;
  }

  .analysis-block {
    padding-inline: 18px;
  }

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

  .goal-controls,
  .time-grid {
    grid-template-columns: 1fr;
  }

  .privacy-note {
    margin-inline: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  .app-header,
  .toolbar,
  .analysis-panel {
    display: none;
  }

  .workspace {
    display: block;
  }

  .editor-panel {
    position: static;
    height: auto;
    border: 0;
  }

  .editor-label textarea {
    min-height: 70vh;
    border: 0;
  }
}
