:root {
  color: #f4ede4;
  background: #070304;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #070304;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell,
.workspace {
  width: 100vw;
  min-height: 100dvh;
  background: #070304;
}

.workspace {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.camera-feed,
.camera-shade,
.ink-canvas,
.guide-canvas,
.glass-plane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-feed {
  z-index: 0;
  object-fit: cover;
  transform: scaleX(-1);
  background: #070304;
}

.camera-shade {
  z-index: 1;
  background: rgba(7, 3, 4, 0.18);
  pointer-events: none;
}

.glass-plane {
  z-index: 2;
  inset: 16px;
  width: auto;
  height: auto;
  border: 1px solid rgba(248, 250, 252, 0.28);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(22, 9, 11, 0.2),
    inset 0 24px 80px rgba(248, 250, 252, 0.05),
    0 24px 80px rgba(7, 3, 4, 0.26);
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 42px;
  height: 42px;
  border-color: rgba(254, 202, 202, 0.82);
  pointer-events: none;
}

.corner-a {
  top: 14px;
  left: 14px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.corner-b {
  top: 14px;
  right: 14px;
  border-top: 2px solid;
  border-right: 2px solid;
}

.corner-c {
  right: 14px;
  bottom: 14px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

.corner-d {
  bottom: 14px;
  left: 14px;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.ink-canvas {
  z-index: 3;
  pointer-events: none;
}

.guide-canvas {
  z-index: 4;
  pointer-events: none;
}

.hud-status,
.tech-strip,
.tool-dock,
.fortune-panel {
  position: fixed;
  z-index: 5;
  border: 1px solid rgba(248, 250, 252, 0.18);
  border-radius: 8px;
  background: rgba(22, 9, 11, 0.62);
  box-shadow: 0 16px 34px rgba(7, 3, 4, 0.24);
  backdrop-filter: blur(14px);
}

.hud-status {
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: calc(100vw - 36px);
  padding: 10px 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: rgba(254, 202, 202, 0.86);
  font-size: 0.76rem;
}

.hud-status h1 {
  margin: 0;
  color: #f4ede4;
  font-size: 1.1rem;
  line-height: 1.1;
  text-wrap: balance;
}

.hud-metrics {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pen-hint,
.status-text,
.stroke-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pen-hint {
  color: #e7b6a5;
  background: rgba(120, 28, 24, 0.44);
}

.status-text {
  color: rgba(248, 250, 252, 0.82);
  background: rgba(248, 250, 252, 0.12);
}

.stroke-pill {
  min-width: 34px;
  color: #e7b6a5;
  background: rgba(120, 28, 24, 0.72);
}

.tech-strip {
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  gap: 8px;
  width: min(260px, calc(100vw - 36px));
  padding: 12px;
}

.tech-strip span {
  color: rgba(248, 250, 252, 0.82);
  font-size: 0.86rem;
  text-wrap: pretty;
}

.tool-dock {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: min(620px, calc(100vw - 36px));
  padding: 10px;
}

.primary-action,
.tool-button,
.dialog-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.primary-action:focus-visible,
.tool-button:focus-visible,
.dialog-button:focus-visible {
  outline: 3px solid rgba(248, 113, 113, 0.42);
  outline-offset: 2px;
}

.primary-action {
  padding: 0 18px;
  color: #fff4ed;
  background: #c23b2f;
  box-shadow: 0 12px 24px rgba(120, 28, 24, 0.24);
}

.primary-action:hover {
  background: #9f2b24;
}

.tool-button {
  min-width: 86px;
  padding: 0 13px;
  color: #f4ede4;
  background: rgba(248, 250, 252, 0.14);
  border-color: rgba(248, 250, 252, 0.16);
}

.tool-button:hover:not(:disabled) {
  border-color: rgba(254, 202, 202, 0.56);
  background: rgba(248, 250, 252, 0.2);
}

.tool-button.primary {
  color: #fff4ed;
  background: rgba(220, 38, 38, 0.92);
  border-color: rgba(254, 202, 202, 0.28);
}

.tool-button.primary:hover:not(:disabled) {
  background: #9f2b24;
}

.tool-button.home-button {
  color: rgba(244, 237, 228, 0.72);
}

.tool-button:disabled {
  cursor: not-allowed;
  color: rgba(226, 232, 240, 0.48);
  background: rgba(22, 9, 11, 0.4);
  border-color: rgba(248, 250, 252, 0.08);
}

.fortune-panel {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 36px));
  padding: 14px;
}

.fortune-panel[hidden] {
  display: none;
}

.fortune-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: #e7b6a5;
  font-size: 0.86rem;
}

.fortune-close {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(248, 250, 252, 0.16);
  border-radius: 8px;
  color: #f4ede4;
  background: rgba(248, 250, 252, 0.12);
  cursor: pointer;
}

.fortune-title {
  margin: 0 0 8px;
  color: #f4ede4;
  font-size: 1.2rem;
  line-height: 1.25;
  text-wrap: balance;
}

.fortune-text {
  margin: 0;
  color: rgba(248, 250, 252, 0.8);
  font-size: 0.95rem;
  line-height: 1.72;
  white-space: pre-wrap;
  text-wrap: pretty;
}

.cover-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: rgba(7, 3, 4, 0.84);
}

.cover-layer.is-hidden {
  display: none;
}

.cover-shell {
  display: grid;
  gap: 18px;
  width: min(720px, 100%);
}

.home-link {
  width: fit-content;
  color: rgba(244, 237, 228, 0.58);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.home-link:hover,
.home-link:focus-visible {
  color: #e7b6a5;
  outline: none;
}

.cover-heading {
  display: grid;
  gap: 8px;
}

.cover-tag {
  width: fit-content;
  padding: 5px 10px;
  border: 1px solid rgba(254, 202, 202, 0.34);
  border-radius: 8px;
  color: #e7b6a5;
  background: rgba(120, 28, 24, 0.4);
  font-size: 0.82rem;
}

.cover-heading h2 {
  margin: 0;
  color: #f4ede4;
  font-size: clamp(2.4rem, 8vw, 5.2rem);
  line-height: 0.98;
  text-wrap: balance;
}

.cover-heading p {
  margin: 0;
  color: rgba(248, 250, 252, 0.78);
  font-size: clamp(1.15rem, 3vw, 1.8rem);
  line-height: 1.25;
  text-wrap: pretty;
}

.listen-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 9px 12px;
  border: 1px solid rgba(248, 250, 252, 0.18);
  border-radius: 8px;
  color: rgba(248, 250, 252, 0.74);
  background: rgba(22, 9, 11, 0.62);
}

.listen-row strong {
  color: #f4ede4;
}

.cover-copy {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cover-copy article {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(248, 250, 252, 0.12);
  border-radius: 8px;
  background: rgba(22, 9, 11, 0.54);
}

.cover-copy h3 {
  margin: 0 0 8px;
  color: #e7b6a5;
  font-size: 1rem;
  line-height: 1.2;
  text-wrap: balance;
}

.cover-copy p {
  margin: 0;
  color: rgba(248, 250, 252, 0.76);
  font-size: 0.94rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.cover-action {
  display: grid;
  justify-items: start;
  gap: 12px;
}

.inline-error {
  width: min(460px, 100%);
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(254, 202, 202, 0.46);
  border-radius: 8px;
  color: #f6d6cf;
  background: rgba(120, 28, 24, 0.58);
  text-wrap: pretty;
}

.confirm-dialog {
  width: min(380px, calc(100vw - 36px));
  padding: 0;
  border: 1px solid rgba(22, 9, 11, 0.16);
  border-radius: 8px;
  color: #16090b;
  background: #ffffff;
  box-shadow: 0 25px 50px rgba(22, 9, 11, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(22, 9, 11, 0.44);
}

.confirm-dialog form {
  padding: 20px;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
  text-wrap: balance;
}

.confirm-dialog p {
  margin: 10px 0 18px;
  color: #6f5a57;
  text-wrap: pretty;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-button {
  min-width: 86px;
  padding: 0 14px;
  color: #16090b;
  background: #f4ede4;
  border-color: rgba(22, 9, 11, 0.12);
}

.dialog-button.danger {
  color: #fef2f2;
  background: #9f2b24;
}

.dialog-button.danger:hover {
  background: #7b201d;
}

@media (max-width: 760px) {
  .glass-plane {
    inset: 10px;
  }

  .hud-status {
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
    justify-content: space-between;
    max-width: none;
  }

  .pen-hint {
    display: none;
  }

  .tech-strip {
    display: none;
  }

  .tool-dock {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .tool-button {
    width: 100%;
    min-width: 0;
  }

  .fortune-panel {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 116px);
    left: max(12px, env(safe-area-inset-left));
    width: auto;
  }

  .cover-layer {
    overflow: auto;
  }

  .cover-copy {
    grid-template-columns: 1fr;
  }
}
