:root {
  --ink: #1b1f2a;
  --muted: #5d6474;
  --line: #dedbd2;
  --bg: #f6f5f1;
  --card: #ffffff;
  --navy: #14213d;
  --gold: #e0a526;
  --risk: #b3261e;
  --ok: #1e7a4f;
  --warn: #8a5a00;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; -webkit-text-size-adjust: 100%; }
a { color: var(--navy); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--navy); color: #fff;
}
.brand { color: #fff; font-weight: 600; text-decoration: none; }
.nav { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.nav a, .nav button { color: #fff; background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; padding: .2rem 0; }
.nav .who { color: #c9cfdd; font-size: .9rem; }

.main { max-width: 980px; margin: 0 auto; padding: 1rem; padding-bottom: 5rem; outline: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; align-items: baseline; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

label { display: block; font-size: .9rem; color: var(--muted); margin: .5rem 0 .2rem; }
input, textarea, select {
  width: 100%; font: inherit; color: inherit; padding: .6rem .7rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea { min-height: 9rem; resize: vertical; }
textarea.memo { min-height: 60vh; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .6rem 1rem; min-height: 44px;
  border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  cursor: pointer; text-decoration: none;
}
button.secondary, .button.secondary { background: #fff; color: var(--navy); }
button.quiet { background: none; border-color: transparent; color: var(--navy); padding: .4rem .5rem; min-height: 0; font-weight: 500; }
button.danger { background: #fff; color: var(--risk); border-color: var(--risk); }
button:disabled { opacity: .55; cursor: default; }
button.rec { background: var(--risk); border-color: var(--risk); }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-top: 1rem; scrollbar-width: none; }
.tabs button {
  background: none; color: var(--muted); border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  padding: .6rem .8rem; white-space: nowrap; font-weight: 600;
}
.tabs button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--gold); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.list li:last-child { border-bottom: 0; }
.case-link { display: block; text-decoration: none; color: inherit; }
.case-link strong { color: var(--navy); }

.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: #eceae3; color: var(--muted); }
.badge.ok { background: #e3f2ea; color: var(--ok); }
.badge.warn { background: #fbf0d9; color: var(--warn); }
.badge.risk { background: #fbe4e2; color: var(--risk); }

.notice { border-left: 4px solid var(--gold); background: #fffaf0; padding: .6rem .8rem; border-radius: 6px; margin: .75rem 0; }
.notice.risk { border-left-color: var(--risk); background: #fdf2f1; }
.law-text { white-space: pre-wrap; background: #faf9f6; border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin: .5rem 0; }
.source { font-size: .85rem; color: var(--muted); }
details summary { cursor: pointer; color: var(--navy); font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.recorder { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.recorder .clock { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4ch; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--risk); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.toast {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 8px; max-width: 92vw; z-index: 10;
}
.toast.risk { background: var(--risk); }
.login { max-width: 380px; margin: 3rem auto; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: #faf9f6; padding: .2rem .4rem; border-radius: 4px; }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; row-gap: .2rem; }
  .nav { gap: .9rem; font-size: .95rem; }
  .nav .who { display: none; }
}
