:root {
  --page-top: #b9bbb3;
  --page-bottom: #a9aca2;
  --surface-page: #fbfbf8;
  --surface-subtle: #f1f3ee;
  --surface-selected: rgba(169, 206, 74, 0.12);
  --surface-hero: rgba(231, 239, 216, 0.68);
  --text-primary: #18211c;
  --text-secondary: rgba(24, 33, 28, 0.64);
  --text-muted: #8a9086;
  --border-default: rgba(24, 33, 28, 0.1);
  --border-strong: rgba(24, 33, 28, 0.18);
  --focus-ring: #99bf3f;
  --accent-green: #a9ce4a;
  --accent-green-strong: #8ab830;
  --accent-ink: #2a2d26;
  --radius-shell: 16px;
  --radius-panel: 8px;
  --radius-field: 6px;
  --shadow-card: 0 1px 3px 1px rgba(0, 0, 0, 0.06), 0 1px 2px 0 rgba(0, 0, 0, 0.1);
  --shadow-shell: 0 14px 34px rgba(40, 43, 36, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.42), transparent 30%),
    linear-gradient(180deg, var(--page-top) 0%, var(--page-bottom) 100%);
  color: var(--text-primary);
  font-family: "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Arial,
    "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.5;
  word-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: auto;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.modal-open {
  overflow: hidden;
}

.page-shell {
  width: min(1180px, calc(100% - 24px));
  height: calc(100vh - 24px);
  margin: 12px auto;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--radius-shell);
  background: rgba(251, 251, 248, 0.98);
  box-shadow: var(--shadow-shell);
}

.app-header {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 70px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-default);
  background: rgba(251, 251, 248, 0.98);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  font-feature-settings: "palt";
}

.app-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-help-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.header-help-button:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.app-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  flex: 1;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow: auto;
}

.input-panel {
  padding: 18px;
  border-right: 1px solid var(--border-default);
  background: var(--surface-subtle);
}

.results-panel {
  padding: 20px;
  background: var(--surface-page);
}

.panel-block,
.control-card,
.speed-card,
.stat-card,
.detail-card,
.advice-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-page);
  box-shadow: var(--shadow-card);
}

.panel-block,
.control-card,
.detail-card,
.advice-card {
  padding: 16px;
}

.panel-heading h2,
.subsection-heading h3,
.detail-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

.timing-block h4 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
}

.panel-heading p,
.subsection-heading p,
.detail-head p,
.helper-text,
.formula-line,
.speed-note,
.advice-text,
.field-label,
.stat-label,
.timer-label {
  color: var(--text-secondary);
}

.panel-heading p,
.subsection-heading p,
.detail-head p,
.helper-text,
.formula-line,
.advice-text {
  margin: 4px 0 0;
  font-size: 0.875rem;
  line-height: 1.65;
}

.field {
  display: block;
  margin-top: 14px;
}

.field-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
}

textarea,
.mini-field input {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-field);
  background: var(--surface-page);
  color: var(--text-primary);
}

textarea {
  min-height: 240px;
  max-height: 36vh;
  padding: 14px;
  font-size: 0.95rem;
  line-height: 1.75;
  resize: vertical;
}

.mini-field {
  display: grid;
  gap: 6px;
}

.mini-field span,
.range-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.mini-field input {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.9375rem;
}

textarea::placeholder,
.mini-field input::placeholder {
  color: var(--text-muted);
}

textarea:focus,
.mini-field input:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(153, 191, 63, 0.12);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.status-note {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.status-note[data-tone="error"] {
  color: #8d3b22;
}

.status-note[data-tone="notice"] {
  color: #5d6f33;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.primary-button {
  border: 1px solid var(--accent-ink);
  background: var(--accent-ink);
  color: #ffffff;
}

.ghost-button {
  border: 1px solid var(--border-default);
  background: #ffffff;
  color: var(--text-primary);
}

.primary-button:hover,
.ghost-button:hover,
.speed-card:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: #1f221d;
  border-color: #1f221d;
}

.ghost-button:hover {
  background: var(--surface-subtle);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.calibration-card {
  grid-column: 1 / -1;
}

.toggle-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.toggle-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-field);
  background: #ffffff;
}

.toggle-card input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-green);
}

.toggle-card span {
  font-size: 0.875rem;
}

.timing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.timing-block {
  display: grid;
  gap: 10px;
}

.target-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.range-field {
  display: grid;
  gap: 8px;
}

.range-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.range-meta strong {
  font-size: 1rem;
  font-weight: 700;
}

.range-meta span {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: rgba(169, 206, 74, 0.18);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--accent-green);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--accent-green);
}

.calibration-actions {
  margin-top: 14px;
}

.result-hero {
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background:
    radial-gradient(circle at 70% 15%, rgba(169, 206, 74, 0.14), transparent 26%),
    linear-gradient(135deg, var(--surface-hero), rgba(251, 251, 248, 0.94) 58%);
}

.result-kicker {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #6c7c39;
  font-feature-settings: "palt";
}

.hero-timer {
  display: grid;
  gap: 4px;
}

.timer-label {
  font-size: 0.95rem;
}

.timer-value {
  font-size: clamp(2.6rem, 5vw, 4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.speed-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.speed-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.speed-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: transparent;
}

.speed-card.active {
  border-color: rgba(169, 206, 74, 0.34);
  background: var(--surface-selected);
}

.speed-card.active::before {
  background: var(--accent-green);
}

.speed-name {
  font-size: 0.875rem;
  font-weight: 700;
}

.speed-time {
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 700;
}

.speed-note {
  font-size: 0.75rem;
  line-height: 1.55;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat-card {
  padding: 14px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
}

.detail-card,
.advice-card {
  margin-top: 12px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-default);
}

.detail-list div:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.detail-list dt {
  color: var(--text-secondary);
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

.advice-label {
  margin: 14px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #6c7c39;
  font-feature-settings: "palt";
  text-transform: uppercase;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 33, 28, 0.38);
  backdrop-filter: blur(6px);
}

.modal-backdrop[aria-hidden="true"] {
  display: none;
}

.modal-dialog {
  width: min(680px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  background: rgba(251, 251, 248, 0.98);
  box-shadow: 0 20px 44px rgba(24, 33, 28, 0.22);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-default);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.65;
}

.modal-close-button {
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1;
}

.modal-close-button:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.modal-content {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.modal-section {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: #ffffff;
  padding: 14px 14px 12px;
}

.modal-section h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.modal-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.75;
}

.modal-list code {
  padding: 1px 6px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-primary);
  font-size: 0.85em;
  font-family: "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Arial,
    "Noto Sans JP", Meiryo, sans-serif;
}

.modal-list li + li {
  margin-top: 4px;
}

.app-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-top: 1px solid var(--border-default);
  background: rgba(251, 251, 248, 0.96);
}

.app-footer a {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.privacy-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.54), transparent 28%),
    linear-gradient(180deg, #c0c2ba 0%, #aeb1a7 100%);
}

.policy-page {
  padding: 24px 12px;
}

.policy-shell {
  width: min(860px, 100%);
  margin: 0 auto;
}

.policy-hero,
.policy-card-page {
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: rgba(251, 251, 248, 0.96);
  box-shadow: var(--shadow-card);
}

.policy-hero {
  padding: 22px 24px;
  background:
    radial-gradient(circle at 82% 16%, rgba(169, 206, 74, 0.12), transparent 22%),
    linear-gradient(135deg, rgba(231, 239, 216, 0.72), rgba(251, 251, 248, 0.96) 62%);
}

.policy-kicker {
  margin: 0 0 8px;
  color: #6c7c39;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.policy-hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.2;
}

.policy-lead {
  margin: 10px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.75;
}

.policy-card-page {
  margin-top: 14px;
  padding: 22px 24px;
}

.policy-card-page a {
  color: #5e7d1d;
  text-decoration: none;
}

.policy-card-page a:hover {
  text-decoration: underline;
}

.policy-meta-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-default);
}

.policy-meta-list div {
  display: grid;
  gap: 2px;
}

.policy-meta-list dt {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
}

.policy-meta-list dd {
  margin: 0;
  font-size: 0.95rem;
}

.policy-section {
  padding-top: 18px;
}

.policy-section h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.policy-section p {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.8;
}

.policy-page-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 2px 0;
}

.policy-page-footer a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  text-decoration: none;
}

.policy-page-footer a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

@media (max-width: 1080px) {
  .page-shell {
    width: min(100% - 16px, 1180px);
    height: calc(100vh - 16px);
    margin: 8px auto;
  }

  .app-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
  }

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

@media (max-width: 920px) {
  .page-shell {
    height: auto;
    margin: 0;
    width: 100%;
  }

  .app-shell {
    min-height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

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

  .panel {
    overflow: visible;
  }

  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--border-default);
  }
}

@media (max-width: 720px) {
  .app-header,
  .input-panel,
  .results-panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .settings-grid,
  .timing-grid,
  .target-inputs,
  .speed-grid,
  .stats-grid,
  .range-grid {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 220px;
    max-height: none;
  }

  .button-row {
    flex-direction: column;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .timer-value {
    font-size: 2.7rem;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-header,
  .modal-content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .policy-page {
    padding: 16px 10px;
  }

  .policy-hero,
  .policy-card-page {
    padding-left: 16px;
    padding-right: 16px;
  }
}
