:root {
  --page-top: #b9bbb3;
  --page-bottom: #a9aca2;
  --surface-page: #fbfbf8;
  --surface-subtle: #f1f3ee;
  --surface-selected: rgba(169, 206, 74, 0.12);
  --text-primary: #18211c;
  --text-secondary: rgba(24, 33, 28, 0.64);
  --text-muted: #8a9086;
  --border-default: rgba(24, 33, 28, 0.1);
  --focus-ring: #99bf3f;
  --accent-green: #a9ce4a;
  --accent-ink: #2a2d26;
  --danger-text: #8d3b22;
  --success-text: #5d6f33;
  --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;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

code {
  padding: 1px 6px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9em;
}

.modal-open {
  overflow: hidden;
}

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

.app-shell {
  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);
  overflow: hidden;
}

.app-header {
  display: grid;
  gap: 2px;
  padding: 12px 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;
}

.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-main {
  padding: 16px;
}

.main-stack {
  display: grid;
  gap: 12px;
}

.panel-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-panel);
  background: var(--surface-page);
  box-shadow: var(--shadow-card);
  padding: 16px;
}

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

.section-heading p,
.field-label,
.status-note {
  color: var(--text-secondary);
}

.section-heading p {
  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 {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-field);
  background: #ffffff;
  color: var(--text-primary);
  padding: 14px;
  font-size: 0.95rem;
  line-height: 1.75;
  resize: vertical;
}

#tagInput {
  min-height: 240px;
}

#resultOutput {
  min-height: 180px;
}

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

textarea:focus,
.segment-card:focus-within,
.header-help-button:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.modal-close-button:focus-visible {
  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;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.status-note[data-tone="error"] {
  color: var(--danger-text);
}

.status-note[data-tone="notice"],
.status-note[data-tone="success"] {
  color: var(--success-text);
}

.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,
.segment-card:hover {
  transform: translateY(-1px);
}

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

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

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

.segment-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-field);
  background: #ffffff;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

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

.segment-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-card span {
  font-size: 0.875rem;
  font-weight: 700;
}

.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;
}

.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(620px, 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 li + li {
  margin-top: 4px;
}

.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: 720px) {
  .page-shell {
    width: calc(100% - 16px);
    margin: 8px auto;
  }

  .app-header,
  .app-main {
    padding-left: 14px;
    padding-right: 14px;
  }

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

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

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

  .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;
  }
}
