:root {
  --bg: #111a2e;
  --panel: #18233c;
  --panel-line: #26355a;
  --text: #eef3ff;
  --text-sub: #a9b8da;
  --accent: #f6edba;
  --accent-ink: #1b2440;
  --blue: #618cd1;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 100vh;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 60vh;
  padding: 16px;
  overflow: hidden;
}

.stage[data-bg="transparent"] {
  background-color: #1a2440;
  background-image:
    linear-gradient(45deg, #222d4b 25%, transparent 25%),
    linear-gradient(-45deg, #222d4b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #222d4b 75%),
    linear-gradient(-45deg, transparent 75%, #222d4b 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}
.stage[data-bg="green"] { background: #00ff00; }
.stage[data-bg="navy"] { background: #1b2a4a; }
.stage[data-bg="white"] { background: #ffffff; }

#avatar {
  display: block;
  width: min(100%, calc((100vh - 32px) * 1296 / 1486));
  height: auto;
  aspect-ratio: 1296 / 1486;
}

.panel {
  background: var(--panel);
  border-left: 1px solid var(--panel-line);
  padding: 24px 22px 28px;
  overflow-y: auto;
  max-height: 100vh;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-icon { width: 44px; height: 44px; }

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.04em;
}

.panel-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-sub);
}

.group {
  padding: 16px 0;
  border-top: 1px solid var(--panel-line);
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  letter-spacing: 0.06em;
}

.keys {
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 400;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.buttons {
  display: grid;
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: #1e2a47;
  font-size: 15px;
  text-align: left;
}

.toggle::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4a5a80;
}

.toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: #283a62;
}

.toggle[aria-pressed="true"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(246, 237, 186, 0.2);
}

.status {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-sub);
}

.link {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: #111a2e;
}

.segmented button {
  flex: 1;
  padding: 9px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  white-space: nowrap;
}

.segmented button[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.note {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-sub);
}

.copy {
  display: flex;
  gap: 6px;
}

.copy input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  background: #111a2e;
  color: var(--text);
  font-size: 12px;
}

.copy button {
  flex: none;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  font-size: 14px;
}

.privacy {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #111a2e;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-sub);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html.obs,
html.obs body {
  background: transparent;
}

html.obs body { display: block; }

html.obs .panel { display: none; }

html.obs .stage {
  height: 100vh;
  padding: 0;
  background: none;
}

html.obs .stage[data-bg="green"] { background: #00ff00; }
html.obs .stage[data-bg="navy"] { background: #1b2a4a; }
html.obs .stage[data-bg="white"] { background: #ffffff; }

html.obs #avatar { width: min(100vw, calc(100vh * 1296 / 1486)); }

@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .stage { min-height: 55vh; }
  #avatar { width: min(100%, calc(60vh * 1296 / 1486)); }
  .panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--panel-line);
    padding: 20px 16px 28px;
  }
}
