:root {
  --background: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f7f9;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #8e8e93;
  --line: rgba(60, 60, 67, 0.16);
  --line-strong: rgba(60, 60, 67, 0.24);
  --focus: #0071e3;
  --brand: #718260;
  --brand-dark: #415d28;
  --brand-soft: #edf1e9;
  --deadline: #8a6416;
  --deadline-soft: #fffaf0;
  --deadline-line: rgba(138, 100, 22, 0.18);
  --ready: #4d6b32;
  --ready-soft: #f1f6ec;
  --ready-line: rgba(103, 138, 54, 0.22);
  --danger: #a63f3a;
  --danger-soft: #fff7f6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 28px rgba(0, 0, 0, 0.05);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  line-height: 1.5;
}

button, input, select { font: inherit; }

/* Header */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: env(safe-area-inset-top) 0 0;
  color: var(--text);
  background: rgba(248, 248, 250, 0.82);
  border-bottom: 1px solid rgba(60, 60, 67, 0.08);
  -webkit-backdrop-filter: saturate(190%) blur(24px);
  backdrop-filter: saturate(190%) blur(24px);
}
.appbar__inner {
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 600px;
  margin: 0 auto;
  padding: 11px 24px 10px;
}
.appbar__logo {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(79, 111, 39, 0.2), 0 1px 2px rgba(0, 0, 0, 0.08);
}
.appbar__wordmark { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.appbar__title {
  margin: 0;
  font-size: 19px;
  font-weight: 730;
  line-height: 1.08;
  letter-spacing: 0;
}
.appbar__tagline { color: var(--text-secondary); font-size: 11px; font-weight: 560; line-height: 1.25; letter-spacing: 0.025em; }

/* Layout */
.container { max-width: 600px; margin: 0 auto; padding: 22px 22px 10px; }

.alert-banner {
  display: block;
  width: 100%;
  margin: 0 0 16px;
  padding: 13px 15px;
  color: var(--ready);
  background: var(--ready-soft);
  border: 1px solid var(--ready-line);
  border-radius: 14px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.alert-banner[hidden] { display: none; }
.alert-banner:active { transform: scale(0.995); opacity: 0.8; }

/* Main checker */
.checker {
  margin-bottom: 24px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.checker__inputs { display: flex; flex-direction: column; gap: 15px; }

.field { display: block; }
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.field__label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
}
.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: #ededf0;
  font-size: 12px;
  font-weight: 650;
  flex-shrink: 0;
}

select, input[type="date"], input[type="number"], input[type="text"], input[type="search"] {
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  background-color: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 450;
  outline: none;
  appearance: none;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
select {
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
select:focus, input:focus {
  background-color: var(--surface);
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.period-note {
  display: block;
  margin-top: 7px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 650;
}

.method-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: #ededf0;
  border-radius: 11px;
}
.method-switch label { position: relative; cursor: pointer; }
.method-switch input { position: absolute; opacity: 0; pointer-events: none; }
.method-switch span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 9px 7px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 550;
  text-align: center;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.method-switch small { color: var(--text-tertiary); font-size: 11px; font-weight: 500; }
.method-switch input:checked + span {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.method-switch input:checked + span small { color: var(--brand-dark); }
.method-switch input:focus-visible + span { outline: 3px solid rgba(0, 113, 227, 0.22); outline-offset: 1px; }

.slide-notice {
  margin: 0;
  color: var(--deadline);
  font-size: 13px;
  font-weight: 650;
}

.notice {
  margin-top: 16px;
  padding: 10px 11px;
  color: var(--text-secondary);
  background: #fbfbfc;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
}
.notice--method.is-normal { background: var(--deadline-soft); border-color: var(--deadline-line); color: #725214; }
.notice--method.is-electronic { background: var(--brand-soft); border-color: rgba(113, 130, 96, 0.18); color: var(--brand-dark); }

/* Results */
.results { display: grid; gap: 9px; margin-top: 18px; }
.tile {
  padding: 14px 15px;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 14px;
}
.tile__caption {
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: none;
}
.tile__date { color: var(--text); font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile--start { background: var(--deadline-soft); border-color: var(--deadline-line); }
.tile--start .tile__caption { color: #8a7347; }
.tile--expiry { background: var(--brand-soft); border-color: rgba(113, 130, 96, 0.2); }
.tile--expiry .tile__caption { color: var(--brand-dark); }
.tile--expiry .tile__date { color: var(--brand-dark); }
.tile--effective {
  background: linear-gradient(180deg, #f5f8ef 0%, #edf4e4 100%);
  border-color: rgba(103, 138, 54, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.tile--effective .tile__caption { color: var(--ready); }
.tile--effective .tile__date { color: var(--ready); font-size: 25px; line-height: 1.2; }
.tile__hint { margin-top: 5px; color: var(--text-secondary); font-size: 12px; }

/* Save and tools */
.save-row { display: flex; gap: 8px; margin-top: 18px; }
.save-row input { flex: 1; min-width: 0; font-size: 14px; }
.btn {
  padding: 11px 17px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary { color: #fff; background: var(--text); }
.btn--primary:hover { background: #000; }
.btn--dark { color: #fff; background: var(--brand-dark); }
.btn--dark:hover { background: #314b1c; }
.btn--ghost { color: var(--text-secondary); background: var(--surface); border: 1px solid var(--line); }
.btn--ghost:hover { color: var(--text); border-color: var(--line-strong); }
.save-message { margin: 7px 2px 0; color: var(--text-secondary); font-size: 14px; font-weight: 600; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tool-row .btn { width: 100%; }

/* Cases */
.cases { margin-top: 26px; }
.cases__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cases__head h2 { margin: 0; color: var(--text); font-size: 18px; font-weight: 700; letter-spacing: 0; }
.cases__head input { max-width: 220px; padding: 9px 12px; font-size: 14px; }
.cases__privacy { margin: 6px 0 12px; color: var(--text-tertiary); font-size: 12px; line-height: 1.5; }

.case-group { margin-bottom: 18px; }
.case-group__title {
  margin: 0 0 8px 2px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
}
.case-group--ready .case-group__title { color: var(--ready); }
.case-item {
  margin-bottom: 8px;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: 15px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.035);
}
.case-item--ready { background: var(--ready-soft); border-color: var(--ready-line); }
.case-item--done { opacity: 0.62; }
.case-item__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.case-item__label {
  min-width: 0;
  padding: 0;
  color: var(--text);
  background: none;
  border: 0;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.case-item__label:hover { color: var(--brand-dark); }
.case-item__badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge--ready { color: #fff; background: var(--ready); }
.badge--waiting { color: var(--deadline); background: var(--deadline-soft); border: 1px solid var(--deadline-line); }
.badge--before { color: var(--text-secondary); background: var(--surface-soft); border: 1px solid var(--line); }
.badge--done { color: var(--text-secondary); background: #e5e5e7; }
.case-item__meta { margin-top: 3px; color: var(--text-secondary); font-size: 13px; }
.case-item__dates { margin-top: 5px; color: var(--text); font-size: 13px; font-weight: 560; }
.case-item__dates strong { color: var(--ready); }
.case-item__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.case-item__actions button {
  padding: 6px 10px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.case-item__actions button:hover { color: var(--text); border-color: var(--line-strong); }
.case-item__actions button.danger:hover { color: var(--danger); border-color: rgba(166, 63, 58, 0.18); }
.cases__empty {
  padding: 22px;
  color: var(--text-tertiary);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  text-align: center;
  font-size: 13px;
}

/* Legal note */
.legal-basis { margin-top: 30px; }
.legal-basis h3, .disclaimer h4 {
  margin: 0 0 10px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.legal-basis__grid { display: grid; gap: 8px; }
@media (min-width: 560px) { .legal-basis__grid { grid-template-columns: repeat(3, 1fr); } }
.legal-basis__grid div {
  padding: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid rgba(60, 60, 67, 0.08);
  border-radius: 13px;
  font-size: 11px;
  line-height: 1.65;
}
.legal-basis__grid strong { display: block; margin-bottom: 4px; color: var(--brand-dark); font-size: 12px; }
.disclaimer { margin-top: 18px; padding: 0 2px; }
.disclaimer p { margin: 0; color: var(--text-tertiary); font-size: 11px; line-height: 1.75; }

.inquiry { margin-top: 26px; text-align: center; }
.inquiry__label { margin: 0 0 10px; color: var(--text-tertiary); font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.inquiry a {
  display: inline-block;
  padding: 11px 28px;
  color: var(--brand-dark);
  background: var(--surface);
  border: 1px solid rgba(113, 130, 96, 0.22);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.inquiry a:hover { background: var(--brand-soft); }

.footer { margin: 44px 0 40px; text-align: center; }
.footer__brand { margin: 0; color: var(--text-tertiary); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }
.footer__brand strong { color: var(--text); letter-spacing: 0; }
.footer__sub { margin: 8px 0 0; color: #c7c7cc; font-size: 9px; letter-spacing: 0.28em; }
.footer__note { margin: 14px auto 0; max-width: 460px; color: var(--text-tertiary); font-size: 11px; line-height: 1.6; }
.footer__links { margin: 6px 0 0; font-size: 12px; }
.footer__links a { color: var(--text-secondary); }

/* Print */
.print-only { display: none; }

@media (max-width: 420px) {
  .appbar__inner { padding-inline: 18px; }
  .container { padding: 18px 16px 8px; }
  .checker { padding: 16px; }
  .save-row { flex-direction: column; }
  .save-row .btn { width: 100%; }
  .tool-row .btn { flex-basis: 100%; }
  .cases__head { align-items: stretch; flex-direction: column; }
  .cases__head input { max-width: none; }
  .case-item__top { align-items: flex-start; }
}

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  .checker { border: none; box-shadow: none; padding: 0; }
  .results .tile { break-inside: avoid; }
  .print-header { text-align: center; margin: 24px 0 28px; }
  .print-header h1 { font-size: 20px; border-bottom: 2px solid #1d1d1f; display: inline-block; padding: 0 40px 10px; }
  .print-header p { font-size: 10px; color: var(--text-secondary); letter-spacing: 0.12em; margin-top: 10px; }
  .print-conditions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 440px; margin: 0 auto 24px; }
  .print-conditions div { border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
  .print-conditions span { display: block; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 3px; }
  .print-footer { text-align: center; margin-top: 32px; border-top: 1px solid var(--line); padding-top: 16px; font-size: 9px; color: var(--text-tertiary); }
  .print-footer p { margin: 2px 0; letter-spacing: 0.12em; }
}