:root {
  /* 背景は少しだけ青みのあるオフホワイト */
  --bg: #f2f7fb;
  --surface: #ffffff;
  --surface-soft: #f7fafd;
  --border: #dfe8f1;
  --text: #263544;
  --muted: #6b7c8f;

  /* アクセントは青緑と淡いブルー */
  --accent: #17a2a8;
  --accent-dark: #12868b;
  --accent-soft: #e3f5f6;
  --blue-soft: #e9f2fb;

  --danger: #c85b57;
  --danger-dark: #a8433f;

  --ok-bg: #e6f5f3;
  --ok-border: #a9ddd4;
  --error-bg: #fdeeed;
  --error-border: #f0c0bd;

  /* 注意書き用の淡い黄色 */
  --warn-bg: #fdf8e6;
  --warn-border: #ecdfb4;
  --warn-text: #6d5c2e;

  /* 角丸は大きめに */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --shadow: 0 1px 2px rgba(38, 53, 68, 0.04), 0 10px 28px rgba(38, 53, 68, 0.06);
  --shadow-sm: 0 1px 2px rgba(38, 53, 68, 0.05);

  /* タブ・カード・フッターの左右を揃えるための共通幅。
     .container は左右 16px の余白を持つので、その分を足した値を max-width にする。 */
  --content-width: 648px;
  --gutter: 16px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  /* 画面ごとの高さの違いでスクロールバーが出たり消えたりすると、
     中央寄せのコンテンツが左右にずれる。常に領域を確保して止める。 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans",
    "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: break-word;
}

/* --- ヘッダー / タブ ------------------------------------------------- */

.site-header {
  padding: 24px var(--gutter) 0;
}

.site-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
}

/* 丸みのあるセグメント切り替え */
.tabs {
  display: flex;
  gap: 4px;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

.tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  border-radius: var(--radius-pill);
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
}

.tab:hover:not(.is-active) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

/* --- レイアウト ------------------------------------------------------ */

.container {
  max-width: calc(var(--content-width) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

/* カード */
.card {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.page-title {
  font-size: 1.3rem;
  margin: 0 0 6px;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

.field {
  margin: 0 0 24px;
  border: 0;
  padding: 0;
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ラベルと、その行の右端に置くボタン */
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 6px;
}

.field-head .label {
  margin: 0;
}

.value {
  margin: 0;
  font-size: 1.05rem;
  word-break: break-all;
}

.help {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.7;
}

.muted {
  color: var(--muted);
  margin-left: 6px;
}

/* --- 入力 ------------------------------------------------------------ */

input[type="text"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input[type="text"]:focus,
textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.7;
}

input[type="file"] {
  width: 100%;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 0.95rem;
}

input:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
}

.radio-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 選べるカードのような見た目のラジオ */
.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 140px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.radio:hover {
  background: var(--accent-soft);
}

.radio:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.radio input {
  accent-color: var(--accent);
}

.key-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
}

.key-row input[type="text"] {
  flex: 1 1 220px;
  min-width: 0;
}

/* --- ボタン ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  box-shadow: 0 2px 8px rgba(23, 162, 168, 0.25);
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-sub {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-sub:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
  width: 100%;
}

.btn-danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
  color: #fff;
}

.btn-small {
  padding: 7px 16px;
  font-size: 0.85rem;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  margin: 24px 0 0;
}

.actions .btn {
  width: 100%;
}

.delete-form {
  display: flex;
  justify-content: center;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* --- 完了表示（チェックアイコン）------------------------------------- */

.done-head {
  text-align: center;
  margin-bottom: 28px;
}

.done-icon {
  width: 88px;
  height: 88px;
  margin: 4px auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  animation: pop 0.35s ease-out both;
}

.done-icon svg {
  width: 44px;
  height: 44px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.done-head .page-title {
  margin: 0 0 6px;
}

.done-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@keyframes pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .done-icon {
    animation: none;
  }
}

/* --- 通知 ------------------------------------------------------------ */

.alert,
.notice {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 0.95rem;
}

.alert {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--danger-dark);
}

.notice-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.error {
  margin: 8px 0 0;
  color: var(--danger-dark);
  font-size: 0.88rem;
}

/* --- テキスト表示 ----------------------------------------------------- */

.preview,
.received-text {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  /* 改行と連続空白を保持する（仕様 7.2）。 */
  white-space: pre-wrap;
  word-break: break-word;
}

.received-text {
  /* 最大高さ400px、超過時は縦スクロール（仕様 7.2）。 */
  max-height: 400px;
  overflow-y: auto;
}

/* ファイル情報をまとめる淡いブルーのボックス */
.file-box {
  padding: 16px 18px;
  background: var(--blue-soft);
  border-radius: var(--radius-sm);
}

.file-box .value {
  font-size: 1rem;
  font-weight: 600;
}

.file-box .help {
  margin-top: 4px;
}

/* --- 注意書き / フッター ---------------------------------------------- */

/* 注意書きは淡い黄色のボックスにまとめる */
.notes {
  margin-top: 24px;
  padding: 18px 20px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  color: var(--warn-text);
}

.notes h2 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.notes ul {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.86rem;
  line-height: 1.8;
}

.notes li + li {
  margin-top: 8px;
}

.site-footer {
  padding: 0 var(--gutter) 40px;
}

/* フッターの注意はグレーのボックス */
.site-footer p {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--muted);
}

/* --- トースト -------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  background: rgba(38, 53, 68, 0.92);
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
}

/* --- 画面幅 ---------------------------------------------------------- */

@media (min-width: 560px) {
  .card {
    padding: 32px 28px;
  }

  /* PC では全幅に広げず、文言に応じた幅にする。
     スマートフォン幅では押しやすさを優先して全幅のまま。 */
  .btn-primary,
  .btn-danger,
  .actions .btn {
    width: auto;
    min-width: 240px;
    padding: 14px 32px;
  }

  .actions {
    flex-direction: row;
  }

  .actions .btn {
    flex: 0 0 auto;
  }
}
