:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5f6b7a;
  --paper: #f7f9fc;
  --surface: #ffffff;
  --line: #d8e0ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #f4b942;
  --danger: #c2410c;
  --danger-soft: #fff3ed;
  --shadow: 0 18px 48px rgba(20, 33, 61, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.08), transparent 34%),
    linear-gradient(300deg, rgba(244, 185, 66, 0.18), transparent 38%),
    var(--paper);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.display-shell,
.monitor-shell,
.staff-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.display-shell,
.monitor-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.display-header,
.staff-header,
.display-footer,
.staff-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
}

.brand p,
.section-label,
.date-card span {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
}

.brand h1 {
  margin: 3px 0 0;
  font-size: clamp(1.7rem, 3.2vw, 3.4rem);
  line-height: 1.08;
}

.date-card {
  min-width: 230px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  text-align: right;
}

.date-card.compact {
  min-width: 200px;
  box-shadow: none;
}

.date-card strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.15rem, 2vw, 1.7rem);
}

.callout {
  flex: 1;
  margin: 34px 0 22px;
  padding: clamp(24px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.monitor-board {
  flex: 1;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: center;
  min-height: 0;
}

.monitor-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--modal-padding, 12px);
  background: rgba(5, 5, 5, 0.88);
}

.monitor-modal:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: var(--modal-padding, 0);
  background: #050505;
}

.monitor-modal button {
  position: fixed;
  top: 14px;
  right: 14px;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 16px;
  font-weight: 900;
  z-index: 51;
}

.modal-stage {
  width: var(--modal-stage-width, min(100vw, calc(100vh * 14 / 9)));
  height: var(--modal-stage-height, auto);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 14 / 9;
  min-height: 0;
  box-shadow: none;
  border-radius: 0;
}

.fullscreen-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
}

.poster-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 14 / 9;
  height: auto;
  min-height: 0;
  align-self: center;
  overflow: hidden;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #050505;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 0;
  padding: 0;
}

.poster-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: #d8e0ea;
  text-align: center;
}

.poster-empty img {
  width: 120px;
  opacity: 0.45;
}

.poster-tile {
  position: absolute;
  overflow: hidden;
  border: 1px solid rgba(244, 185, 66, 0.85);
  border-radius: 3px;
  background: #111827;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34);
  z-index: 3;
  display: grid;
  place-items: center;
  contain: layout paint;
}

.poster-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  pointer-events: none;
  user-select: none;
  background: #050505;
}

.preview-button {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: 48px;
  height: 48px;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(20, 33, 61, 0.24);
  cursor: pointer;
}

.preview-button::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 3px solid #ffffff;
  border-radius: 3px;
}

.monitor-board.presentation-preview,
.monitor-board:fullscreen {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: var(--preview-padding, 8px);
  background: #050505;
  grid-template-columns: var(--preview-stage-width, minmax(0, 1fr)) var(--preview-sidebar-width, 280px);
  gap: var(--preview-gap, 12px);
  align-items: center;
  justify-content: center;
  align-content: center;
  overflow: hidden;
}

.monitor-board.presentation-preview .preview-button,
.monitor-board:fullscreen .preview-button {
  display: none;
}

.monitor-board.presentation-preview .poster-stage,
.monitor-board:fullscreen .poster-stage {
  min-height: 0;
  width: var(--preview-stage-width, min(100%, calc((100vh - 16px) * 14 / 9)));
  height: var(--preview-stage-height, auto);
  aspect-ratio: 14 / 9;
  box-shadow: none;
  justify-self: center;
}

.monitor-board.presentation-preview .call-sidebar,
.monitor-board:fullscreen .call-sidebar {
  width: var(--preview-sidebar-width, 280px);
  height: var(--preview-stage-height, calc(100vh - 16px));
  min-height: 0;
  box-shadow: none;
}

.poster-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(26, 211, 230, 0.82);
  background: rgba(7, 16, 31, 0.78);
  z-index: 1;
}

.poster-cell > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(216, 224, 234, 0.72);
  font-size: 0.86rem;
  font-weight: 800;
  pointer-events: none;
}

.poster-stage:not(.is-editor-stage) .poster-cell {
  border-color: transparent;
  background: transparent;
}

.poster-stage:not(.is-editor-stage) .poster-tile {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.editor-stage .poster-cell {
  z-index: 1;
  pointer-events: none;
  border-color: transparent;
  background: transparent;
}

.editor-stage .poster-cell > span {
  display: none;
}

.poster-stage.has-posters:not(.is-editor-stage) {
  gap: 0;
  padding: 0;
}

.call-sidebar {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: min(420px, 100%);
  gap: 12px;
}

.sidebar-brand {
  gap: 10px;
}

.sidebar-brand img {
  width: 46px;
  height: 46px;
}

.sidebar-brand h1 {
  font-size: 1.2rem;
  line-height: 1.15;
}

.store-logo {
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.store-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.x-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #050505;
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 900;
}

.x-qr {
  width: 82px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
}

.sidebar-date {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  box-shadow: none;
  text-align: left;
}

.sidebar-date strong {
  white-space: nowrap;
  font-size: clamp(0.95rem, 1.25vw, 1.25rem);
}

.number-stack {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.number-stack .number-card {
  min-height: 86px;
}

.number-stack .number-card strong {
  font-size: clamp(2.1rem, 4vw, 3.8rem);
}

.compact-empty {
  min-height: 240px;
  padding: 10px;
}

.compact-empty p {
  font-size: 1.15rem;
}

.sidebar-note {
  margin: auto 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.section-label {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.number-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
}

.number-card {
  min-height: 170px;
  border: 2px solid #c8d9e6;
  border-radius: 8px;
  background: #fffdfa;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 24px rgba(20, 33, 61, 0.1);
}

.number-card strong {
  font-size: clamp(3.5rem, 11vw, 8.5rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.empty-state {
  min-height: 50vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state img {
  width: 130px;
  height: 130px;
  opacity: 0.55;
}

.empty-state p {
  margin: 0;
  font-size: clamp(1.4rem, 2.8vw, 2.6rem);
  font-weight: 800;
}

.display-footer,
.staff-footer {
  color: var(--muted);
  font-size: 1rem;
}

.display-footer p {
  margin: 0;
}

.staff-shell {
  max-width: 960px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(100%, 620px);
}

.login-form {
  margin-top: 22px;
}

.staff-panel {
  margin-top: 28px;
  display: grid;
  gap: 20px;
}

.share-panel,
.store-panel,
.editor-panel,
.add-form,
.list-panel,
.danger-zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(20, 33, 61, 0.08);
  padding: 22px;
}

.upload-form {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.upload-button {
  display: inline-grid;
  place-items: center;
  min-height: 46px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.upload-button input {
  display: none;
}

.editor-stage-wrap {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2f7;
}

.editor-stage {
  min-height: 0;
  cursor: default;
}

.editor-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background:
    linear-gradient(to right, rgba(26, 211, 230, 0.95) 1px, transparent 1px) 0 0 / calc(100% / 7) 100%,
    linear-gradient(to bottom, rgba(26, 211, 230, 0.95) 1px, transparent 1px) 0 0 / 100% calc(100% / 3),
    linear-gradient(to right, transparent calc(100% - 1px), rgba(26, 211, 230, 0.95) calc(100% - 1px)),
    linear-gradient(to bottom, transparent calc(100% - 1px), rgba(26, 211, 230, 0.95) calc(100% - 1px));
}

.drop-hint {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(216, 224, 234, 0.55);
  border-radius: 8px;
  color: #d8e0ea;
  font-weight: 800;
  pointer-events: none;
}

.editor-stage.is-dragging {
  outline: 4px solid rgba(15, 118, 110, 0.6);
}

.editor-stage .poster-tile {
  cursor: grab;
  outline: 2px solid rgba(244, 185, 66, 0.68);
  outline-offset: -2px;
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  box-shadow: none;
}

.editor-stage .poster-tile.is-selected {
  outline: 4px solid #22c55e;
  outline-offset: -4px;
}

.editor-stage .poster-tile.is-blocked {
  outline: 4px solid #ef4444;
  outline-offset: -4px;
}

.editor-stage .poster-tile.is-moving {
  cursor: grabbing;
  opacity: 0.62;
  z-index: 8;
  box-shadow: none;
  will-change: left, top, width, height;
}

.editor-stage .poster-tile.is-moving img {
  visibility: hidden;
}

.poster-resize {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.9);
  z-index: 8;
}

.resize-nw {
  top: 3px;
  left: 3px;
  cursor: nwse-resize;
}

.resize-ne {
  top: 3px;
  right: 3px;
  cursor: nesw-resize;
}

.resize-sw {
  bottom: 3px;
  left: 3px;
  cursor: nesw-resize;
}

.resize-se {
  right: 3px;
  bottom: 3px;
  cursor: nwse-resize;
}

.placement-preview {
  position: absolute;
  border: 4px dashed #22c55e;
  background: rgba(34, 197, 94, 0.12);
  pointer-events: none;
  z-index: 7;
}

.placement-preview.is-blocked {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.14);
}

.compact-danger,
.compact-action {
  min-height: 46px;
}

.poster-controls {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.poster-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.poster-control label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.poster-control span {
  color: var(--ink);
  font-size: 1rem;
}

.share-panel {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  gap: 20px;
}

.share-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

.share-panel p {
  margin: 8px 0 14px;
  color: var(--muted);
}

.share-panel a {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.qr-code {
  width: 180px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.store-form-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.store-form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.store-form-grid input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b8c4d2;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

.logo-field {
  grid-column: 1 / -1;
}

.store-preview {
  margin: 14px 0;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
}

.store-logo-preview {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.add-form label,
.panel-title h2,
.danger-zone h2 {
  margin: 0;
  font-size: 1.2rem;
}

.input-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.input-row input {
  width: 100%;
  min-height: 58px;
  border: 1px solid #b8c4d2;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 1.35rem;
  font-weight: 800;
}

.input-row input:focus {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  border-color: var(--primary);
}

.primary-button,
.danger-button,
.delete-button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.helper-text,
.danger-zone p,
.empty-list {
  margin: 10px 0 0;
  color: var(--muted);
}

.panel-title,
.staff-item,
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title span {
  color: var(--muted);
  font-weight: 800;
}

.staff-list {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.staff-item {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfe;
  min-width: 0;
}

.staff-number {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.staff-time {
  display: block;
  margin-left: 0;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.delete-button {
  background: #344256;
}

.delete-button:hover {
  background: #1f2937;
}

.danger-zone {
  background: var(--danger-soft);
  border-color: #fed7c2;
}

.danger-button {
  background: var(--danger);
  flex: 0 0 auto;
}

.danger-button:hover {
  background: #9a3412;
}

.staff-footer {
  margin-top: 18px;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .display-shell,
  .monitor-shell,
  .staff-shell {
    width: min(100% - 16px, 1180px);
    padding: 8px 0;
  }

  .display-header,
  .staff-header,
  .display-footer,
  .staff-footer,
  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .date-card {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

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

  .callout {
    margin-top: 18px;
    padding: 18px;
  }

  .number-grid {
    grid-template-columns: 1fr;
  }

  .monitor-board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "calls"
      "posters";
    gap: 6px;
    align-content: start;
    flex: 0 0 auto;
  }

  .poster-stage {
    grid-area: posters;
  }

  .call-sidebar {
    grid-area: calls;
  }

  .poster-stage {
    min-height: 0;
  }

  .call-sidebar {
    min-height: 0;
    padding: 8px 60px 8px 10px;
    gap: 6px;
  }

  .store-links {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 2;
  }

  .x-button {
    width: 42px;
    height: 42px;
  }

  .x-qr {
    display: none;
  }

  .sidebar-brand {
    gap: 8px;
  }

  .sidebar-brand img {
    width: 42px;
    height: 42px;
  }

  .sidebar-brand h1 {
    font-size: 1rem;
  }

  .sidebar-date {
    padding: 8px 10px;
  }

  .sidebar-date strong {
    font-size: clamp(0.95rem, 3.6vw, 1.1rem);
  }

  .number-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 0;
  }

  .number-stack .number-card {
    min-height: 64px;
  }

  .number-stack .number-card strong {
    font-size: clamp(1.7rem, 9vw, 3rem);
  }

  .preview-button {
    display: none;
  }

  .compact-empty {
    min-height: 44px;
  }

  .sidebar-note {
    margin-top: 0;
  }

  .number-card {
    min-height: 150px;
  }

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

  .share-panel {
    grid-template-columns: 1fr;
  }

  .store-form-grid {
    grid-template-columns: 1fr;
  }

  .qr-code {
    width: min(220px, 100%);
    height: auto;
  }

  .primary-button,
  .danger-button {
    width: 100%;
  }

  .staff-item {
    align-items: stretch;
    flex-direction: column;
  }
}
