:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e8eef5;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --danger: #f07178;
  --danger-bg: #5c2b2f;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.view {
  min-height: 100vh;
}

.view.hidden {
  display: none;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  margin: 2rem auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

#login-form input {
  width: 100%;
  font-size: 1.25rem;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b0f14;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  cursor: pointer;
  background: #2a3548;
  color: var(--text);
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #334155;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.error.hidden,
.hint.hidden {
  display: none;
}

.notice {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1.5rem;
  line-height: 1.4;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid #243044;
}

.main-tabs {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.panel.hidden {
  display: none;
}

.btn.danger {
  background: var(--danger-bg);
  color: #fff;
  border: 1px solid var(--danger);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gallery-title {
  margin: 0;
  font-size: 1.15rem;
}

.gallery-status {
  color: var(--muted);
  font-size: 0.9rem;
}

.gallery-status.hidden {
  display: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.gallery-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #243044;
  display: flex;
  flex-direction: column;
}

.gallery-thumb-link {
  display: block;
  aspect-ratio: 4 / 3;
  background: #000;
}

.gallery-thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-card-meta {
  padding: 0.45rem 0.55rem 0;
  font-size: 0.8rem;
}

.gallery-card-title {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  display: block;
}

.gallery-card-date {
  color: var(--muted);
  display: block;
  margin-top: 0.15rem;
}

.gallery-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem;
  margin-top: auto;
}

.gallery-card-actions .btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 0.45rem 0.35rem;
  text-align: center;
}

.viewer-actions {
  margin-top: 1rem;
}

.viewer-actions.hidden {
  display: none;
}

.settings-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.settings-warn {
  font-size: 0.9rem;
  color: #f0c674;
  line-height: 1.45;
  margin: 0 0 1rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.vault-key-field {
  width: 100%;
  font-size: 14px;
  font-family: ui-monospace, monospace;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b0f14;
  color: var(--text);
  margin-bottom: 0.75rem;
  resize: vertical;
}

.vault-key-field.hidden {
  display: none;
}

.vault-import-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.gallery-thumb-link {
  position: relative;
}

.gallery-enc-badge {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
}

.gallery-thumb.thumb-locked {
  background: repeating-linear-gradient(
    -45deg,
    #1a2332,
    #1a2332 8px,
    #243044 8px,
    #243044 16px
  );
  min-height: 100px;
}

.brand {
  font-weight: 600;
}

.decoy-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 52px);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  max-width: 320px;
}

.empty-state h2 {
  color: var(--text);
  font-weight: 500;
}

.workspace {
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

.panel .stage.hidden {
  display: none;
}

.camera-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.55);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

#edit-canvas {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius);
  background: #000;
  cursor: crosshair;
  touch-action: none;
}

#edit-canvas.canvas-text-mode {
  cursor: text;
  touch-action: manipulation;
}

.edit-tools {
  margin-top: 0.75rem;
}

.tool-mode {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mode-btn {
  flex: 1;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.text-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.9rem;
}

.text-tools.hidden {
  display: none;
}

.text-tools label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.text-hint {
  flex: 1 1 100%;
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.brush-tools.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-card {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

#text-input {
  width: 100%;
  font-size: 16px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b0f14;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.brush-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.brush-tools label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hint {
  font-size: 0.85rem;
  color: #f0c674;
  margin-bottom: 0.75rem;
}

.success {
  color: #98c379;
}

.link-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
}

#share-url {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b0f14;
  color: var(--text);
}

.viewer-page .viewer {
  max-width: 640px;
  margin: 2rem auto;
  padding: 0 1rem;
  text-align: center;
}

.viewer-page img {
  max-width: 100%;
  border-radius: var(--radius);
}

.viewer-page .meta {
  color: var(--muted);
  font-size: 0.9rem;
}