:root {
  --accent: #0e8f91;
  --accent-bright: #18aaa4;
  --accent-dark: #07666c;
  --navy: #071526;
  --navy-mid: #0d253d;
  --navy-soft: #15334d;
  --gold: #cda85b;
  --gold-light: #ead49b;
  --ink: #122b40;
  --paper: #edf4f6;
  --card: rgba(255, 255, 255, 0.94);
  --card-solid: #ffffff;
  --line: rgba(22, 57, 77, 0.14);
  --line-light: rgba(255, 255, 255, 0.12);
  --muted: #5c7284;
  --ok: #11765b;
  --bad: #b93850;
  --warn: #8a5c0e;
  --shadow: 0 18px 45px rgba(2, 18, 34, 0.14), 0 3px 10px rgba(2, 18, 34, 0.06);
  --shadow-hover: 0 24px 55px rgba(2, 18, 34, 0.2), 0 6px 16px rgba(2, 18, 34, 0.08);
  --radius: 22px;
  --radius-small: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--navy);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  line-height: 1.7;
  background:
    radial-gradient(circle at 8% 12%, rgba(19, 144, 145, 0.2), transparent 28rem),
    radial-gradient(circle at 91% 72%, rgba(205, 168, 91, 0.14), transparent 32rem),
    linear-gradient(145deg, #06111f 0%, #0b2137 48%, #071526 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 86%);
}

::selection {
  color: #fff;
  background: var(--accent);
}

button,
input,
textarea,
select {
  font-family: inherit;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  padding: 20px clamp(20px, 5vw, 56px);
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 86% 12%, rgba(24, 170, 164, 0.22), transparent 18rem),
    linear-gradient(110deg, rgba(7, 21, 38, 0.98), rgba(13, 37, 61, 0.96));
  border-bottom: 1px solid rgba(205, 168, 91, 0.76);
  box-shadow: 0 12px 40px rgba(0, 8, 18, 0.3);
}

.app-header::before,
.app-header::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border: 1px solid rgba(234, 212, 155, 0.11);
  border-radius: 50%;
  pointer-events: none;
}

.app-header::before {
  top: -104px;
  right: 15%;
  box-shadow:
    48px 48px 0 -1px rgba(13, 37, 61, 0.2),
    48px 48px 0 0 rgba(234, 212, 155, 0.08);
}

.app-header::after {
  right: -55px;
  bottom: -125px;
  width: 240px;
  height: 240px;
}

.brand,
.chain-status {
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-mark {
  color: #fff;
  font-size: clamp(25px, 4vw, 32px);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}

.brand-mark::after {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  margin-left: 12px;
  vertical-align: middle;
  background: linear-gradient(90deg, var(--gold-light), transparent);
}

.brand-sub {
  margin-top: 6px;
  color: #a9c2d2;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.chain-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  color: #dffbf1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(8, 29, 44, 0.55);
  border: 1px solid rgba(116, 224, 188, 0.22);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
}

.status-dot {
  color: #4bd2a2;
  font-size: 11px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(75, 210, 162, 0.78));
}

.chain-status.bad {
  color: #ffe5e8;
  border-color: rgba(255, 118, 139, 0.28);
}

.chain-status.bad .status-dot {
  color: #ff7189;
  filter: drop-shadow(0 0 6px rgba(255, 113, 137, 0.75));
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  padding: 0 max(8px, calc((100vw - 860px) / 2));
  background: rgba(7, 21, 38, 0.86);
  border-bottom: 1px solid var(--line-light);
  box-shadow: 0 8px 28px rgba(0, 8, 18, 0.2);
  backdrop-filter: blur(18px) saturate(130%);
}

.tab {
  position: relative;
  flex: 1;
  min-height: 58px;
  padding: 15px 10px;
  color: #8fa9ba;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  background: transparent;
  border: 0;
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.tab::after {
  content: "";
  position: absolute;
  right: 26%;
  bottom: -1px;
  left: 26%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transform: scaleX(0.35);
  transition: opacity 180ms ease, transform 180ms ease;
}

.tab:hover {
  color: #f2f8fa;
  background: rgba(255, 255, 255, 0.035);
}

.tab.active {
  color: #fff;
}

.tab.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.tab:focus-visible,
.btn:focus-visible,
.form input:focus-visible,
.form textarea:focus-visible,
.form select:focus-visible,
.verify-input input:focus-visible {
  outline: 3px solid rgba(24, 170, 164, 0.34);
  outline-offset: 2px;
}

.content {
  width: min(100%, 860px);
  min-height: calc(100vh - 230px);
  margin: 0 auto;
  padding: 38px 18px 76px;
}

.panel {
  display: none;
  padding: clamp(24px, 5vw, 44px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(242, 248, 249, 0.93));
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.panel.active {
  display: block;
  animation: panel-in 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

h2 {
  margin: 0 0 8px;
  color: var(--navy-mid);
  font-size: clamp(24px, 4vw, 31px);
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: 0.045em;
}

h2::before {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-bottom: 13px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(205, 168, 91, 0.25);
}

.lead {
  max-width: 690px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #254359;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.form label[hidden] {
  display: none;
}

.form input,
.form textarea,
.form select,
.verify-input input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(27, 68, 91, 0.18);
  border-radius: 11px;
  box-shadow: inset 0 1px 2px rgba(9, 27, 41, 0.025);
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.form textarea {
  min-height: 116px;
  resize: vertical;
}

.form input:hover,
.form textarea:hover,
.form select:hover,
.verify-input input:hover {
  border-color: rgba(14, 143, 145, 0.38);
}

.form input:focus,
.form textarea:focus,
.form select:focus,
.verify-input input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(14, 143, 145, 0.11), 0 8px 20px rgba(8, 70, 77, 0.07);
}

.form input[type="file"] {
  padding: 8px;
  color: var(--muted);
}

.form input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 11px;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: #e9f5f4;
  border: 0;
  border-radius: 8px;
}

.field-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
}

.btn {
  min-height: 44px;
  padding: 10px 18px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.025em;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(22, 57, 77, 0.18);
  border-radius: 11px;
  box-shadow: 0 5px 14px rgba(8, 30, 45, 0.06);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease;
}

.btn:hover {
  background: #fff;
  border-color: rgba(14, 143, 145, 0.4);
  box-shadow: 0 9px 20px rgba(8, 30, 45, 0.1);
  transform: translateY(-1px);
}

.btn:active {
  box-shadow: 0 3px 9px rgba(8, 30, 45, 0.08);
  transform: translateY(0);
}

.btn.primary {
  color: #fff;
  background: linear-gradient(125deg, var(--accent-dark), var(--accent-bright));
  border-color: rgba(7, 102, 108, 0.56);
  box-shadow: 0 10px 24px rgba(7, 102, 108, 0.23), inset 0 1px 0 rgba(255, 255, 255, 0.19);
}

.btn.primary:hover {
  background: linear-gradient(125deg, #06565c, #159d99);
  border-color: var(--accent-dark);
  box-shadow: 0 13px 29px rgba(7, 102, 108, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.form > .btn.primary {
  min-height: 52px;
  margin-top: 5px;
  font-size: 14px;
}

.btn.danger {
  color: var(--bad);
  background: rgba(255, 250, 251, 0.9);
  border-color: rgba(185, 56, 80, 0.34);
  box-shadow: none;
}

.btn.danger:hover {
  background: #fff3f5;
  border-color: rgba(185, 56, 80, 0.58);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.result {
  margin-top: 24px;
  padding: clamp(18px, 4vw, 26px);
  background: var(--card);
  border: 1px solid rgba(22, 57, 77, 0.12);
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(6, 29, 47, 0.1);
}

.result.hidden,
.qr-reader.hidden {
  display: none;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.verdict .icon {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  font-size: 18px;
  background: var(--ok);
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(10, 66, 50, 0.16);
}

.verdict.genuine {
  color: var(--ok);
}

.verdict.tampered,
.verdict.notfound {
  color: var(--bad);
}

.verdict.tampered .icon,
.verdict.notfound .icon {
  background: var(--bad);
}

.kv {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 9px 16px;
  margin: 18px 0;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
  font-weight: 700;
}

.kv dd {
  min-width: 0;
  margin: 0;
  color: #1c3a50;
  font-weight: 500;
  word-break: break-word;
}

.hash,
.code-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.code-badge {
  display: inline-block;
  max-width: 100%;
  padding: 5px 9px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.025em;
  background: linear-gradient(135deg, #edf8f7, #e5f0f2);
  border: 1px solid rgba(14, 143, 145, 0.15);
  border-radius: 7px;
  word-break: break-all;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.qr-box canvas,
.qr-box img {
  border: 10px solid #fff;
  border-radius: 8px;
  box-shadow: 0 15px 34px rgba(4, 27, 43, 0.16);
}

.media-preview {
  margin-top: 18px;
}

.media-preview img,
.media-preview video {
  display: block;
  max-width: 100%;
  max-height: 520px;
  margin-inline: auto;
  object-fit: contain;
  background: #e8f0f2;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.verify-input {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.verify-input input {
  flex: 1;
  min-width: 210px;
}

.qr-reader {
  max-width: 340px;
  margin: 18px auto 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.chain-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 23px;
}

.validate-msg {
  flex: 1 1 100%;
  min-height: 1.7em;
  font-size: 12px;
  font-weight: 700;
}

.validate-msg.ok {
  color: var(--ok);
}

.validate-msg.bad {
  color: var(--bad);
}

.record-flow {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 21px;
}

.record-flow::before {
  content: "";
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 13px;
  width: 2px;
  background: linear-gradient(to bottom, var(--gold-light), var(--gold) 28%, var(--accent) 76%, rgba(14, 143, 145, 0.2));
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(14, 143, 145, 0.26);
}

.flow-card {
  position: relative;
  margin-left: 43px;
  padding: clamp(17px, 4vw, 23px);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.99), rgba(247, 251, 252, 0.96));
  border: 1px solid rgba(27, 68, 91, 0.13);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(7, 29, 46, 0.09);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.flow-card:hover {
  border-color: rgba(14, 143, 145, 0.22);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.flow-card::before {
  content: "";
  position: absolute;
  top: 21px;
  left: -38px;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: 4px solid #f4f8f9;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgba(14, 143, 145, 0.8),
    0 0 16px rgba(24, 170, 164, 0.65);
}

.flow-card:has(.category-badge[data-category="イベント"])::before {
  background: var(--gold);
  box-shadow:
    0 0 0 2px rgba(205, 168, 91, 0.84),
    0 0 18px rgba(205, 168, 91, 0.65);
}

.flow-card.tampered {
  background: linear-gradient(145deg, #fffafb, #fff2f4);
  border-color: rgba(185, 56, 80, 0.46);
}

.flow-card.tampered::before {
  background: var(--bad);
  box-shadow:
    0 0 0 2px rgba(185, 56, 80, 0.74),
    0 0 16px rgba(185, 56, 80, 0.48);
}

.flow-head,
.flow-child-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.flow-labels,
.flow-child-labels {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.flow-title {
  margin: 8px 0 3px;
  color: #102d43;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: 0.025em;
}

.category-badge,
.child-count,
.integrity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.045em;
  line-height: 1.4;
}

.category-badge {
  color: #075e64;
  background: #def3f1;
  border: 1px solid rgba(14, 143, 145, 0.12);
}

.category-badge[data-category="イベント"] {
  color: #72520c;
  background: #f7edcf;
  border-color: rgba(205, 168, 91, 0.22);
}

.category-badge[data-category="活動報告"] {
  color: #334f79;
  background: #e6edf7;
  border-color: rgba(67, 101, 151, 0.13);
}

.child-count {
  color: #566b7b;
  background: #eef3f5;
  border: 1px solid rgba(27, 68, 91, 0.1);
}

.integrity-badge {
  flex: 0 0 auto;
  color: var(--ok);
  background: #e7f5ee;
  border: 1px solid rgba(17, 118, 91, 0.11);
}

.integrity-badge.bad {
  color: var(--bad);
  background: #fce9ed;
  border-color: rgba(185, 56, 80, 0.11);
}

.flow-date {
  color: #9a7428;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.flow-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.flow-excerpt {
  margin: 12px 0 0;
  color: #314d60;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-line;
}

.flow-block {
  margin-top: 12px;
  color: #718695;
  font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.035em;
}

.flow-media {
  display: block;
  width: 100%;
  max-height: 330px;
  margin-top: 15px;
  object-fit: cover;
  background: #e8f0f2;
  border: 1px solid rgba(27, 68, 91, 0.1);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(4, 27, 43, 0.11);
}

.orphan-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 13px 0 0;
  padding: 5px 9px;
  color: #6a7780;
  font-size: 11px;
  font-weight: 600;
  background: #f0f3f4;
  border: 1px solid rgba(84, 106, 119, 0.13);
  border-radius: 8px;
}

.orphan-note::before {
  content: "◇";
  color: var(--gold);
}

.child-records {
  position: relative;
  display: grid;
  gap: 12px;
  margin: 21px 0 0 13px;
  padding: 1px 0 1px 33px;
}

.child-records::before {
  content: "";
  position: absolute;
  top: -20px;
  bottom: 29px;
  left: 4px;
  width: 19px;
  border-bottom: 2px solid rgba(14, 143, 145, 0.5);
  border-left: 2px solid rgba(205, 168, 91, 0.62);
  border-radius: 0 0 0 16px;
  filter: drop-shadow(0 0 4px rgba(14, 143, 145, 0.16));
}

.flow-child {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 13px;
  align-items: center;
  min-width: 0;
  padding: 13px 14px;
  background: linear-gradient(135deg, #f7fbfb, #eef6f6);
  border: 1px solid rgba(14, 143, 145, 0.16);
  border-radius: 13px;
  box-shadow: 0 7px 18px rgba(5, 37, 50, 0.07);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.flow-child::before {
  content: "";
  position: absolute;
  top: 27px;
  left: -30px;
  width: 29px;
  height: 2px;
  background: linear-gradient(90deg, rgba(14, 143, 145, 0.55), rgba(14, 143, 145, 0.2));
}

.flow-child::after {
  content: "";
  position: absolute;
  top: 23px;
  left: -4px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 2px solid #f3f8f8;
  border-radius: 50%;
  box-shadow: 0 0 7px rgba(14, 143, 145, 0.42);
}

.flow-child:hover {
  z-index: 1;
  border-color: rgba(14, 143, 145, 0.33);
  box-shadow: 0 11px 25px rgba(5, 37, 50, 0.12);
  transform: translateX(3px);
}

.flow-child.tampered {
  background: linear-gradient(135deg, #fff8f9, #fdeff2);
  border-color: rgba(185, 56, 80, 0.38);
}

.flow-child.tampered::after {
  background: var(--bad);
  box-shadow: 0 0 7px rgba(185, 56, 80, 0.4);
}

.flow-child-copy {
  min-width: 0;
}

.flow-child-head {
  gap: 8px;
}

.flow-child .flow-title {
  margin-top: 6px;
  font-size: 14px;
}

.flow-child .flow-date {
  font-size: 10px;
}

.flow-child .integrity-badge {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 9px;
}

.flow-child .flow-block {
  margin-top: 7px;
  font-size: 9px;
}

.flow-child-media {
  width: 104px;
  height: 78px;
  max-height: none;
  margin: 0;
  border-radius: 9px;
}

.flow-child > .notice {
  max-width: 160px;
  margin: 0;
}

.relink-controls {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.relink-btn,
.relink-confirm,
.relink-cancel {
  min-height: 30px;
  padding: 5px 10px;
  color: var(--accent-dark);
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  background: rgba(237, 248, 247, 0.76);
  border: 1px solid rgba(14, 143, 145, 0.18);
  border-radius: 8px;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.relink-btn:hover,
.relink-confirm:hover {
  background: #e1f3f1;
  border-color: rgba(14, 143, 145, 0.4);
  box-shadow: 0 5px 12px rgba(7, 102, 108, 0.09);
}

.relink-confirm:disabled {
  cursor: wait;
  opacity: 0.62;
}

.relink-cancel {
  color: var(--muted);
  background: transparent;
  border-color: rgba(22, 57, 77, 0.13);
}

.relink-history {
  color: var(--muted);
  font-size: 10px;
}

.relink-history summary {
  min-height: 30px;
  padding: 5px 8px;
  cursor: pointer;
  font-weight: 700;
  border-radius: 8px;
}

.relink-history summary:hover {
  color: var(--accent-dark);
  background: rgba(237, 248, 247, 0.72);
}

.relink-history[open] {
  flex-basis: 100%;
}

.relink-history ol,
.verify-relink-history ol {
  display: grid;
  gap: 7px;
  margin: 7px 0 0;
  padding: 10px 10px 10px 28px;
  background: rgba(240, 246, 247, 0.88);
  border: 1px solid rgba(22, 57, 77, 0.09);
  border-radius: 9px;
}

.relink-history li,
.verify-relink-history li {
  padding-left: 2px;
  color: #355165;
}

.relink-history li span,
.relink-history li small,
.verify-relink-history li span,
.verify-relink-history li small {
  display: block;
}

.relink-history li small,
.verify-relink-history li small {
  color: #7b8f9c;
  font-size: 9px;
}

.relink-form {
  flex: 1 1 100%;
  display: grid;
  gap: 9px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(244, 250, 250, 0.98), rgba(235, 245, 246, 0.96));
  border: 1px solid rgba(14, 143, 145, 0.16);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.relink-form[hidden] {
  display: none;
}

.relink-form label {
  display: grid;
  gap: 5px;
  color: #385469;
  font-size: 10px;
  font-weight: 800;
}

.relink-select {
  width: 100%;
  min-height: 39px;
  padding: 7px 10px;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(27, 68, 91, 0.17);
  border-radius: 8px;
}

.relink-select:focus-visible,
.relink-btn:focus-visible,
.relink-confirm:focus-visible,
.relink-cancel:focus-visible,
.relink-history summary:focus-visible {
  outline: 3px solid rgba(24, 170, 164, 0.26);
  outline-offset: 2px;
}

.relink-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.relink-error {
  min-height: 0;
  margin: 0;
  color: var(--bad);
  font-size: 10px;
  font-weight: 700;
}

.relink-error:empty {
  display: none;
}

.flow-child .relink-controls {
  margin-top: 8px;
}

.flow-child .relink-history ol {
  min-width: min(310px, 72vw);
}

.verify-relink-history {
  margin: 20px 0;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.verify-relink-history h3 {
  margin: 0 0 9px;
  color: #17374d;
  font-size: 14px;
}

.verify-relink-history ol {
  margin-top: 0;
  font-size: 12px;
}

.verify-relink-history li small {
  font-size: 10px;
}

.empty-state {
  padding: 42px 24px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(39, 83, 105, 0.27);
  border-radius: 16px;
}

.chain-view {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.block {
  position: relative;
  padding: 17px 18px;
  overflow: hidden;
  color: #17374d;
  font-size: 12px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.98), rgba(240, 247, 248, 0.96));
  border: 1px solid rgba(27, 68, 91, 0.14);
  border-left: 4px solid var(--accent);
  border-radius: 15px;
  box-shadow: 0 11px 27px rgba(7, 29, 46, 0.09);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.block::after {
  content: "";
  position: absolute;
  top: -35px;
  right: -35px;
  width: 95px;
  height: 95px;
  background: radial-gradient(circle, rgba(14, 143, 145, 0.1), transparent 68%);
  border-radius: 50%;
  pointer-events: none;
}

.block:hover {
  box-shadow: 0 17px 36px rgba(7, 29, 46, 0.13);
  transform: translateY(-2px);
}

.block.broken {
  background: linear-gradient(145deg, #fffafb, #fff0f3);
  border-left-color: var(--bad);
}

.block .bk-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
  color: #102d43;
  font-weight: 900;
  letter-spacing: 0.025em;
}

.block .bk-type {
  margin-left: 5px;
  color: var(--accent-dark);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.block .hash {
  margin-top: 5px;
  padding: 7px 9px;
  color: #6a8291;
  font-size: 10px;
  line-height: 1.55;
  background: rgba(225, 236, 239, 0.7);
  border: 1px solid rgba(27, 68, 91, 0.07);
  border-radius: 7px;
  word-break: break-all;
}

.block .bk-data {
  margin-top: 9px;
  padding: 12px;
  overflow: auto;
  color: #bcd8dc;
  font: 10px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  background:
    linear-gradient(145deg, #0a1e30, #102c42);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  box-shadow: inset 0 1px 10px rgba(0, 0, 0, 0.16);
}

.block .tamper {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.block .tamper .btn {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 10px;
}

.chain-connector {
  position: relative;
  align-self: center;
  width: 3px;
  height: 66px;
  background: linear-gradient(to bottom, var(--gold), var(--accent));
  border-radius: 999px;
  box-shadow: 0 0 9px rgba(14, 143, 145, 0.22);
}

.chain-connector::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}

.chain-connector span {
  position: absolute;
  top: 20px;
  left: 18px;
  width: 245px;
  color: #708695;
  font: 9px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.025em;
  white-space: nowrap;
}

.app-footer {
  padding: 22px 16px 30px;
  color: #88a1b2;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.notice {
  padding: 9px 12px;
  margin-top: 11px;
  font-size: 11px;
  line-height: 1.6;
  border-radius: 9px;
}

.notice.warn {
  color: var(--warn);
  background: #fff7e5;
  border: 1px solid rgba(205, 168, 91, 0.36);
}

@media (max-width: 620px) {
  .app-header {
    min-height: 80px;
    padding: 17px 18px;
  }

  .brand-mark {
    font-size: 24px;
  }

  .brand-sub {
    font-size: 9px;
  }

  .status-label {
    display: none;
  }

  .chain-status {
    width: 32px;
    height: 32px;
    justify-content: center;
    padding: 0;
  }

  .tabs {
    padding: 0;
    overflow-x: auto;
  }

  .tab {
    min-width: 88px;
    min-height: 53px;
    padding: 12px 5px;
    font-size: 11px;
  }

  .content {
    padding: 22px 11px 50px;
  }

  .panel {
    padding: 22px 17px 26px;
    border-radius: 18px;
  }

  h2 {
    font-size: 23px;
  }

  .lead {
    margin-bottom: 23px;
  }

  .flow-head {
    flex-direction: column;
    gap: 8px;
  }

  .record-flow::before {
    left: 9px;
  }

  .flow-card {
    margin-left: 31px;
    padding: 16px 14px;
  }

  .flow-card::before {
    top: 20px;
    left: -29px;
    width: 12px;
    height: 12px;
    border-width: 3px;
  }

  .child-records {
    margin-left: 4px;
    padding-left: 25px;
  }

  .child-records::before {
    left: 1px;
    width: 15px;
  }

  .flow-child {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 9px;
    padding: 11px;
  }

  .flow-child::before {
    left: -23px;
    width: 22px;
  }

  .flow-child-head {
    flex-direction: column;
    gap: 5px;
  }

  .flow-child-media {
    width: 76px;
    height: 64px;
  }

  .flow-child > .notice {
    grid-column: 1 / -1;
    max-width: none;
  }

  .relink-form {
    padding: 10px;
  }

  .relink-actions > button {
    flex: 1 1 auto;
  }

  .kv {
    grid-template-columns: 98px minmax(0, 1fr);
    gap: 8px 10px;
  }

  .verify-input {
    flex-direction: column;
  }

  .verify-input input,
  .verify-input .btn {
    width: 100%;
  }

  .chain-connector span {
    display: none;
  }

  .block {
    padding: 14px 12px;
  }

  .block .bk-head {
    flex-wrap: wrap;
  }
}

@media (max-width: 390px) {
  .flow-child {
    grid-template-columns: 1fr;
  }

  .flow-child-media {
    width: 100%;
    height: 105px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
