:root {
  color-scheme: light;
  --ink: #10233b;
  --ink-soft: #526174;
  --navy: #10233b;
  --navy-light: #1d3654;
  --canvas: #e9eef5;
  --surface: #ffffff;
  --line: #ccd6e3;
  --accent: #29c89a;
  --accent-dark: #087b5f;
  --danger: #b4233f;
  --shadow: 0 22px 60px rgba(16, 35, 59, 0.14);
  --note-yellow: #ffd85a;
  --note-green: #75e0a7;
  --note-blue: #78c7ff;
  --note-pink: #ff97c8;
  --note-orange: #ffad63;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(41, 200, 154, 0.1), transparent 28rem),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

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

button,
a {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: relative;
  z-index: 20;
  min-height: 68px;
  padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 8px 26px rgba(10, 28, 49, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  font-size: 1.08rem;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.brand img {
  border-radius: 9px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  color: #d8e4f2;
  font-size: 0.82rem;
  font-weight: 650;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #f6b84a;
}

.connection-status.is-online .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(41, 200, 154, 0.16);
}

.connection-status.is-offline .status-dot {
  background: #ff6b7e;
}

.view {
  min-height: calc(100vh - 68px);
  min-height: calc(100dvh - 68px);
}

.home-view {
  width: min(100%, 36rem);
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 6.5rem) clamp(1rem, 4vw, 3rem);
}

.join-panel {
  padding: clamp(1.5rem, 5vw, 2.6rem);
  border: 1px solid rgba(16, 35, 59, 0.08);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-kicker,
.display-eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.join-panel h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 7vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.intro {
  margin-bottom: 2rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}

.join-form,
.note-composer {
  display: flex;
  flex-direction: column;
}

.join-form label,
.name-field label {
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 750;
}

.code-input,
.name-field input,
.note-composer textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.code-input:focus,
.name-field input:focus,
.note-composer textarea:focus {
  border-color: var(--accent-dark);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(41, 200, 154, 0.14);
}

.code-input {
  height: 4.3rem;
  padding: 0.8rem 1rem;
  text-align: center;
  font-size: clamp(1.6rem, 8vw, 2.15rem);
  font-weight: 850;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.primary-button {
  min-height: 3.35rem;
  padding: 0.8rem 1.15rem;
  color: #082d24;
  font-weight: 820;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  box-shadow: 0 9px 20px rgba(20, 151, 115, 0.2);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease;
}

.primary-button:hover {
  filter: brightness(1.04);
  box-shadow: 0 12px 24px rgba(20, 151, 115, 0.25);
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:focus-visible,
.text-link:focus-visible,
.back-link:focus-visible,
.brand:focus-visible {
  outline: 3px solid #53e7ba;
  outline-offset: 3px;
}

.primary-button:disabled {
  filter: grayscale(0.45);
  opacity: 0.58;
  cursor: not-allowed;
  box-shadow: none;
}

.join-form .primary-button {
  margin-top: 0.45rem;
}

.field-error {
  min-height: 1.4rem;
  margin: 0.35rem 0 0.4rem;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 650;
}

.participant-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(1.1rem, 4vw, 2.8rem) clamp(1rem, 4vw, 2rem) 4rem;
}

.board-heading {
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.9rem;
}

.back-link {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 1.45rem;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
}

.board-code-label {
  margin-bottom: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.board-code-label strong {
  color: var(--accent-dark);
  letter-spacing: 0.13em;
}

.board-heading h1 {
  margin-bottom: 0.3rem;
  font-size: clamp(1.65rem, 5vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.board-description {
  margin-bottom: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.state-panel {
  padding: 1.1rem 1.2rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.state-error {
  color: #78142a;
  border-color: #efb4c1;
  background: #fff1f4;
}

.note-composer {
  padding: clamp(1.15rem, 4vw, 2rem);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(16, 35, 59, 0.12);
}

.composer-topline,
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.composer-topline h2,
.section-heading h2 {
  margin-bottom: 0.85rem;
  font-size: 1.05rem;
  letter-spacing: -0.012em;
}

.character-count {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.note-composer textarea {
  min-height: 9.5rem;
  padding: 1rem;
  resize: vertical;
  font-size: 1.06rem;
  line-height: 1.55;
}

.composer-row {
  margin-top: 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.72fr);
  gap: 1.25rem;
  align-items: end;
}

.color-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  border: 0;
}

.color-picker legend {
  width: 100%;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-weight: 750;
}

.color-choice {
  position: relative;
  width: 2.65rem;
  height: 2.65rem;
  display: block;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(16, 35, 59, 0.12);
  cursor: pointer;
}

.color-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.color-choice span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.color-choice:has(input:checked) {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
}

.color-choice:has(input:focus-visible) {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}

.color-yellow,
.note-yellow {
  background: var(--note-yellow);
}

.color-green,
.note-green {
  background: var(--note-green);
}

.color-blue,
.note-blue {
  background: var(--note-blue);
}

.color-pink,
.note-pink {
  background: var(--note-pink);
}

.color-orange,
.note-orange {
  background: var(--note-orange);
}

.name-field {
  display: flex;
  flex-direction: column;
}

.name-field label span {
  color: var(--ink-soft);
  font-weight: 500;
}

.name-field input {
  min-height: 2.85rem;
  padding: 0.65rem 0.8rem;
}

.pin-button {
  margin-top: 0.2rem;
}

.closed-message {
  margin: 0.8rem 0 0;
  padding: 0.8rem 1rem;
  color: #744416;
  border-radius: 12px;
  background: #fff3d5;
}

.recent-section {
  margin-top: 2.3rem;
}

.text-link {
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 760;
  text-underline-offset: 0.2em;
}

.recent-notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: 1rem;
}

.note-card {
  min-height: 10rem;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.2rem;
  color: #142338;
  border-radius: 2px;
  box-shadow: 0 10px 24px rgba(16, 35, 59, 0.14);
  overflow-wrap: anywhere;
}

.note-card p {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.42;
  white-space: pre-wrap;
}

.note-author {
  color: rgba(16, 35, 59, 0.68);
  font-size: 0.76rem;
  font-weight: 720;
}

.empty-message {
  padding: 1.4rem;
  color: var(--ink-soft);
  text-align: center;
  border: 1px dashed #aebaca;
  border-radius: 14px;
}

.board-view {
  position: relative;
  padding: 1.5rem clamp(1rem, 3vw, 2.2rem) 2rem;
  overflow: hidden;
  background-color: #dce4ee;
  background-image: radial-gradient(rgba(46, 67, 91, 0.22) 1px, transparent 1px);
  background-size: 22px 22px;
}

.display-heading {
  position: relative;
  z-index: 5;
  min-height: 6rem;
  padding: 1.15rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border: 1px solid rgba(16, 35, 59, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 35px rgba(16, 35, 59, 0.1);
  backdrop-filter: blur(12px);
}

.display-heading h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.display-heading p {
  margin-bottom: 0;
  color: var(--ink-soft);
}

.display-code {
  min-width: 12rem;
  padding: 0.75rem 1rem;
  text-align: center;
  border-radius: 13px;
  background: var(--navy);
}

.display-code span {
  display: block;
  color: #a9bbcf;
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.display-code strong {
  display: block;
  margin-top: 0.2rem;
  color: #fff;
  font-size: 1.45rem;
  letter-spacing: 0.16em;
}

.display-canvas {
  position: relative;
  min-height: calc(100vh - 12.5rem);
  min-height: calc(100dvh - 12.5rem);
  margin-top: 1.25rem;
}

.display-note {
  position: absolute;
  left: clamp(0%, var(--x), calc(100% - 15rem));
  top: clamp(0%, var(--y), calc(100% - 13rem));
  width: clamp(11rem, 17vw, 15rem);
  min-height: clamp(10rem, 15vw, 13rem);
  padding: clamp(1rem, 1.7vw, 1.45rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  color: #142338;
  box-shadow: 0 13px 30px rgba(16, 35, 59, 0.2);
  transform: rotate(var(--rotation));
  transform-origin: center;
  overflow-wrap: anywhere;
}

.display-note p {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  line-height: 1.38;
  white-space: pre-wrap;
}

.display-state {
  position: relative;
  z-index: 4;
  margin-top: 1.2rem;
}

.display-empty {
  position: absolute;
  inset: 11rem 1rem 2rem;
  display: grid;
  place-items: center;
  color: #617184;
  font-size: 1.1rem;
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 100;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(calc(100% - 2rem), 24rem);
  padding: 0.95rem 1.1rem;
  color: #fff;
  font-weight: 680;
  line-height: 1.4;
  border-radius: 13px;
  background: var(--navy);
  box-shadow: 0 15px 38px rgba(16, 35, 59, 0.3);
}

@media (max-width: 760px) {
  .app-header {
    min-height: 62px;
  }

  .brand {
    font-size: 1rem;
  }

  .brand img {
    width: 30px;
    height: 30px;
  }

  .connection-status {
    padding-inline: 0.5rem;
  }

  .connection-status span:last-child {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .view {
    min-height: calc(100dvh - 62px);
  }

  .home-view {
    min-height: calc(100dvh - 62px);
    padding-top: 2.5rem;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .color-choice {
    width: 2.85rem;
    height: 2.85rem;
  }

  .recent-notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .display-heading {
    align-items: flex-start;
  }

  .display-code {
    min-width: 8.5rem;
  }

  .display-note {
    width: 11rem;
    min-height: 10rem;
  }
}

@media (max-width: 480px) {
  .join-panel {
    padding: 1.35rem;
    border-radius: 18px;
  }

  .participant-shell {
    padding-inline: 0.85rem;
  }

  .note-composer {
    padding: 1rem;
    border-radius: 18px;
  }

  .recent-notes {
    grid-template-columns: 1fr;
  }

  .note-card {
    min-height: 8rem;
  }

  .board-view {
    padding-inline: 0.7rem;
  }

  .display-heading {
    padding: 0.9rem;
    gap: 0.7rem;
  }

  .display-heading p:not(.display-eyebrow) {
    display: none;
  }

  .display-code {
    min-width: 7rem;
    padding-inline: 0.6rem;
  }

  .display-code strong {
    font-size: 1rem;
  }
}

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