:root {
  --bg: #f4efe7;
  --panel: rgba(255, 251, 247, 0.92);
  --ink: #1f2933;
  --muted: #5c6b73;
  --accent: #9d3c2a;
  --accent-strong: #7f2716;
  --line: rgba(31, 41, 51, 0.12);
  --shadow: 0 20px 50px rgba(68, 47, 37, 0.16);
  --viewer-vh: 1vh;
  --viewer-toolbar-height: 48px;
  --page-gutter: clamp(14px, 2.4vw, 32px);
}

html {
  scrollbar-gutter: stable;
  overflow-y: scroll;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(157, 60, 42, 0.18), transparent 26%),
    radial-gradient(circle at bottom right, rgba(31, 41, 51, 0.12), transparent 30%),
    linear-gradient(135deg, #efe7db 0%, #f7f4ef 44%, #ebe0d2 100%);
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(18px, 2.4vw, 28px) var(--page-gutter) clamp(32px, 4vw, 56px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(10px);
}

.hero-panel {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-toolbar {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.viewer-admin-body {
  min-width: 320px;
}

.admin-shell {
  padding: calc(76px + env(safe-area-inset-top, 0px)) 0 0;
}

.admin-shell > section {
  padding-inline: var(--page-gutter);
}

.login-section {
  display: flex;
  justify-content: center;
}

#loginPanel {
  width: min(100%, 440px);
}

#loginPanel h2 {
  text-align: center;
}

#loginForm {
  width: 100%;
}

.admin-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding:
    calc(8px + env(safe-area-inset-top, 0px))
    var(--page-gutter)
    8px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  background: rgba(255, 251, 247, 0.96);
  box-shadow: 0 12px 30px rgba(68, 47, 37, 0.12);
  align-items: start;
  flex-direction: row;
  gap: 18px;
}

.admin-topbar-left,
.admin-topbar-center,
.admin-topbar-right {
  min-width: 0;
}

.admin-topbar-left {
  flex: 1 1 auto;
}

.admin-topbar-center {
  flex: 0 0 auto;
  align-self: center;
}

.admin-topbar-center .inline-actions {
  align-items: center;
  justify-content: center;
}

.admin-topbar-right {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.admin-topbar h1 {
  margin-bottom: 4px;
  font-size: clamp(1.05rem, 1.5vw, 1.4rem);
  line-height: 1.2;
}

.admin-topbar .eyebrow {
  margin-bottom: 4px;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
}

.admin-topbar .lede {
  margin-bottom: 0;
  font-size: 0.86rem;
  line-height: 1.35;
}

.admin-topbar .hero-toolbar {
  width: auto;
  gap: 8px;
  justify-items: end;
}

.admin-profile-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
}

.admin-profile-status .material-icons {
  font-size: 22px;
  line-height: 1;
}

.admin-role-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-session-toggle {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
}

.admin-session-toggle .material-icons {
  font-size: 28px;
  line-height: 1;
}

.admin-create-action {
  width: 44px;
  min-width: 44px;
  height: 44px;
  border-radius: 14px;
}

.admin-create-action .material-icons {
  font-size: 24px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--accent);
}

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

.lede,
.muted {
  color: var(--muted);
}

.status-chip {
  border-radius: 999px;
  border: 1px solid rgba(157, 60, 42, 0.28);
  padding: 10px 14px;
  color: var(--accent-strong);
  background: rgba(157, 60, 42, 0.08);
  white-space: nowrap;
}

.subtle-chip {
  color: var(--ink);
  background: rgba(31, 41, 51, 0.05);
  border-color: var(--line);
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

textarea {
  resize: vertical;
  font-family: "Courier New", monospace;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

button.ghost {
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  border: 1px solid var(--line);
}

.actions,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-list {
  display: grid;
  gap: 16px;
}

.table-shell {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 34px rgba(68, 47, 37, 0.08);
}

.projects-table {
  width: 100%;
}

#projectsListPanel,
#usersListPanel {
  padding-inline: clamp(18px, 2.4vw, 32px);
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.view-switch-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  color: var(--ink);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.view-switch-button.active {
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.view-switch-button .material-icons {
  font-size: 18px;
  line-height: 1;
}

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

.project-grid-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 20px;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(31, 41, 51, 0.16),
    0 8px 24px rgba(31, 41, 51, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.project-grid-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 6px 18px rgba(31, 41, 51, 0.12),
    0 18px 40px rgba(31, 41, 51, 0.14);
}

.project-card-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  background: linear-gradient(180deg, #fcfdff 0%, #f6f9fc 100%);
}

.project-card-heading {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.project-card-title {
  color: #26415c;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.project-card-subtitle {
  color: #6f8090;
  font-size: 0.92rem;
  line-height: 1.45;
}

.project-card-content {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 20px;
}

.project-card-updated-label,
.project-card-supporting-label {
  color: #667781;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-card-updated-value {
  color: #1f2933;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.45;
}

.project-card-supporting {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.project-card-supporting-item {
  display: grid;
  gap: 6px;
  padding: 12px 0 0;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  color: var(--ink);
  font-size: 0.9rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.project-card-bottombar {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  background: #fff;
}

.project-grid-empty {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px;
  border: 1px dashed rgba(31, 41, 51, 0.2);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.56);
}

.project-grid-empty .material-icons {
  font-size: 32px;
  color: var(--accent);
}

table.dataTable {
  width: 100% !important;
  border-collapse: collapse;
  margin: 0 !important;
  background: transparent;
}

table.dataTable thead th {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 18px 16px !important;
  border-bottom: 1px solid rgba(31, 41, 51, 0.1) !important;
  background: rgba(244, 239, 231, 0.88);
}

table.dataTable tbody td {
  vertical-align: top;
  padding: 16px !important;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08) !important;
}

table.dataTable tbody tr:last-child td {
  border-bottom: 0 !important;
}

table.dataTable tbody tr:hover {
  background: rgba(157, 60, 42, 0.04);
}

.dt-container {
  padding: 14px 16px 12px;
}

.dt-container table.dataTable {
  margin-inline: -16px !important;
  width: calc(100% + 32px) !important;
}

.dt-container .dt-search input,
.dt-container .dt-length select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.dt-container .dt-search input {
  min-width: 220px;
  min-height: 42px;
}

.dt-container .dt-layout-row {
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.dt-container .dt-layout-cell {
  margin: 0;
}

.dt-container .dt-layout-row:not(:last-child) {
  margin-bottom: 14px;
}

.dt-container .dt-paging .dt-paging-button {
  min-width: 38px;
  min-height: 38px;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
}

.dt-container .dt-paging .dt-paging-button.current,
.dt-container .dt-paging .dt-paging-button.current:hover {
  color: white !important;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%) !important;
  box-shadow: 0 10px 24px rgba(127, 39, 22, 0.22);
}

.dt-container .dt-paging .dt-paging-button:not(.disabled):hover {
  color: var(--ink) !important;
  background: rgba(31, 41, 51, 0.06) !important;
}

.dt-container .dt-info,
.dt-container .dt-length,
.dt-container .dt-search,
.dt-container .dt-paging {
  color: var(--muted);
}

.table-project-cell,
.table-date-cell,
.share-links-cell {
  display: grid;
  gap: 6px;
}

.viewer-project-link {
  color: var(--accent-strong);
  text-decoration: none;
}

.viewer-project-link:hover {
  text-decoration: underline;
}

.table-actions {
  flex-wrap: wrap;
}

.table-action {
  white-space: nowrap;
}

.shared-projects-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 92px;
}

.shared-project-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(157, 60, 42, 0.08);
  font-weight: 700;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
}

.icon-action .material-icons {
  font-size: 19px;
  line-height: 1;
}

.icon-action.shared-projects-button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.danger-action {
  color: #8a1f11;
  border-color: rgba(138, 31, 17, 0.18);
}

.share-link-item {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 41, 51, 0.05);
}

.share-link-item + .share-link-item {
  margin-top: 8px;
}

.project-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.project-card header,
.inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.link-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.share-link {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 41, 51, 0.05);
  overflow-wrap: anywhere;
}

.project-checklist {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.project-check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 14px;
  background: rgba(244, 239, 231, 0.7);
}

.project-check-item input {
  width: auto;
  margin-top: 3px;
}

.project-check-item span {
  display: grid;
  gap: 4px;
}

.project-dialog {
  width: min(1120px, calc(100vw - (var(--page-gutter) * 2)));
  max-width: calc(100vw - (var(--page-gutter) * 2));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(250, 246, 240, 0.98);
  box-shadow: var(--shadow);
}

.project-dialog::backdrop {
  background: rgba(31, 41, 51, 0.45);
  backdrop-filter: blur(4px);
}

.shared-projects-dialog {
  width: min(760px, calc(100vw - (var(--page-gutter) * 2)));
}

.dialog-form {
  padding: 28px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.shared-projects-search {
  gap: 7px;
}

.shared-projects-search span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.shared-projects-table-shell {
  height: min(58vh, 360px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.shared-projects-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.shared-projects-table th,
.shared-projects-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.shared-projects-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(244, 239, 231, 0.96);
}

.shared-projects-table tr:last-child td {
  border-bottom: 0;
}

.shared-projects-table td {
  overflow-wrap: anywhere;
}

.shared-projects-table td:first-child {
  width: 45%;
  color: var(--ink);
}

.shared-projects-table td:last-child {
  color: var(--muted);
}

.shared-projects-table strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.shared-projects-empty {
  min-height: 100%;
  padding: 18px;
}

.hidden {
  display: none;
}

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

@media (max-width: 960px) {
  .admin-shell {
    padding-top: calc(90px + env(safe-area-inset-top, 0px));
  }

  .page-shell:not(.admin-shell) {
    padding: 20px var(--page-gutter) 40px;
  }

  .panel,
  #projectsListPanel {
    padding: 20px;
  }

  .hero-panel,
  .section-head,
  .inline-actions,
  .dt-container .dt-layout-row {
    align-items: stretch;
    flex-direction: column;
  }

  .project-card-topbar {
    flex-direction: column;
  }

  .project-card-bottombar.inline-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .project-card-bottombar .icon-action {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
  }

  .project-card-supporting {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    align-items: start;
    flex-direction: row;
    gap: 16px;
  }

  .admin-topbar-left {
    flex: 1 1 0;
  }

  .admin-topbar-center,
  .admin-topbar .hero-toolbar {
    width: auto;
    justify-items: end;
  }

  .admin-topbar-center .inline-actions {
    flex-direction: row;
    align-items: center;
  }

  .admin-topbar-right {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }
}

.viewer-body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: 0;
  padding-bottom: 0;
}

.viewer-shell {
  background:
    radial-gradient(circle at top left, rgba(157, 60, 42, 0.16), transparent 22%),
    linear-gradient(180deg, #efe7db 0%, #edf1f4 100%);
}

.viewer-header {
  padding:
    calc(8px + env(safe-area-inset-top, 0px))
    var(--page-gutter)
    10px;
}

.viewer-header h1 {
  margin-bottom: 4px;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.1;
}

.viewer-header .eyebrow {
  margin-bottom: 5px;
  font-size: 0.68rem;
}

.viewer-header .muted {
  margin-bottom: 0;
  line-height: 1.25;
}

.viewer-date-highlight {
  color: #9d3c2a;
  font-weight: 800;
}

.viewer-date-separator {
  color: #64748b;
}

.viewer-toolbar {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--viewer-toolbar-height);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 251, 247, 0.9);
  box-shadow: 0 14px 32px rgba(68, 47, 37, 0.18);
  backdrop-filter: blur(10px);
}

.viewer-toolbar-handle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.06);
  touch-action: none;
  flex: 0 0 auto;
}

.viewer-toolbar-handle .material-icons {
  font-size: 16px;
  line-height: 1;
}

.viewer-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.viewer-tool .material-icons {
  font-size: 18px;
  line-height: 1;
}

.viewer-tool.active,
.viewer-tool.view-active {
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.viewer-measure-readout {
  min-width: 140px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.viewer-topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.viewer-canvas {
  min-height: 70vh;
  min-height: calc((var(--viewer-vh) * 100) - 180px);
  width: auto;
  margin: 0 var(--page-gutter) 20px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #f3efe8 0%, #dfe5ea 100%);
}

.viewer-canvas-full {
  min-height: 0;
  height: calc((var(--viewer-vh) * 100) - 140px);
}

.viewer-error {
  padding: 0 var(--page-gutter) 20px;
  color: #8a1f11;
}

.viewer-canvas.measure-active {
  cursor: crosshair;
}

.viewer-canvas.panel-size-active {
  cursor: pointer;
}

.panel-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}

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

.panel-detail-dialog {
  width: min(var(--panel-detail-width, 486px), 100vw);
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(31, 41, 51, 0.14);
  border-radius: 18px 0 0 18px;
  background: rgba(255, 251, 247, 0.98);
  box-shadow: 0 28px 80px rgba(31, 41, 51, 0.28);
  padding: clamp(12px, 1.8vw, 18px);
  clip-path: inset(0 0 0 100% round 18px 0 0 18px);
  opacity: 0;
  transition:
    clip-path 360ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 360ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: clip-path, opacity;
  pointer-events: auto;
  position: relative;
}

.panel-detail-backdrop.is-open .panel-detail-dialog {
  clip-path: inset(0 0 0 0 round 18px 0 0 18px);
  opacity: 1;
}

.panel-detail-backdrop.is-closing .panel-detail-dialog {
  clip-path: inset(0 0 0 0 round 18px 0 0 18px);
  opacity: 0;
}

.panel-detail-resize-handle {
  position: absolute;
  top: 0;
  left: -7px;
  width: 14px;
  height: 100%;
  cursor: ew-resize;
  touch-action: none;
}

.panel-detail-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.panel-detail-header h2 {
  margin-bottom: 4px;
  font-size: clamp(1.25rem, 2.2vw, 1.8rem);
}

.panel-detail-meta {
  margin-bottom: 0;
}

.panel-detail-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(31, 41, 51, 0.04);
  cursor: pointer;
}

.panel-detail-close:hover {
  background: rgba(31, 41, 51, 0.08);
}

.panel-detail-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 10px;
}

.panel-detail-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(31, 41, 51, 0.04);
  cursor: pointer;
}

.panel-detail-tool:hover {
  background: rgba(31, 41, 51, 0.08);
}

.panel-detail-tool .material-icons {
  font-size: 20px;
  line-height: 1;
}

.panel-detail-zoom {
  min-width: 48px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: right;
}

.panel-detail-canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 12px;
  background: #f8f3eb;
  cursor: grab;
  touch-action: none;
  user-select: none;
  overscroll-behavior: contain;
}

.panel-detail-canvas-wrap.is-panning {
  cursor: grabbing;
}

.panel-detail-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 260px;
  background: #f8f3eb;
  user-select: none;
}

.panel-detail-cuts {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.panel-detail-cuts p {
  margin: 0 0 8px 0;
}

.panel-detail-cut-group + .panel-detail-cut-group {
  margin-top: 10px;
}

.panel-detail-cut-group-label {
  margin: 0 0 6px 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.panel-detail-cut-list {
  margin: 0;
  padding-left: 1.2rem;
}

.panel-detail-cut-list li + li {
  margin-top: 6px;
}

.viewer-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 999px;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
}

.viewer-icon-link {
  width: 44px;
  min-width: 44px;
  padding: 0;
}

.viewer-icon-link .material-icons {
  font-size: 22px;
  line-height: 1;
}

@media (max-width: 960px) {
  .hero-panel,
  .section-head,
  .project-card header,
  .inline-actions,
  .dialog-header,
  .share-link-item {
    flex-direction: column;
    align-items: stretch;
  }

  .project-card-bottombar.inline-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .admin-topbar {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .admin-topbar-left {
    flex: 1 1 0;
    min-width: 0;
  }

  .admin-topbar-center,
  .admin-topbar-right {
    flex: 0 0 auto;
  }

  .admin-topbar-center .inline-actions,
  .admin-topbar-right {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }

  .hero-toolbar {
    justify-items: stretch;
  }

  .project-dialog {
    width: calc(100vw - (var(--page-gutter) * 2));
    max-width: calc(100vw - (var(--page-gutter) * 2));
  }

  .viewer-toolbar {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(calc(100vw - (var(--page-gutter) * 2)), 420px);
    max-width: none;
    justify-content: center;
    flex-wrap: wrap;
  }

  .viewer-measure-readout {
    width: 100%;
    text-align: center;
  }

  .panel-detail-backdrop {
    padding: 0;
  }

  .panel-detail-dialog {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)) 12px;
  }

  .panel-detail-header {
    gap: 12px;
    margin-bottom: 10px;
  }

  .panel-detail-header h2 {
    font-size: clamp(1.1rem, 5vw, 1.35rem);
  }

  .panel-detail-tools {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .panel-detail-canvas {
    min-height: 220px;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    padding-top: calc(90px + env(safe-area-inset-top, 0px));
  }

  .admin-topbar {
    align-items: center;
    gap: 8px;
  }

  .admin-topbar-left {
    min-width: 0;
  }

  .admin-topbar-center,
  .admin-topbar-right {
    flex: 0 0 auto;
  }

  .admin-profile-status,
  .admin-session-toggle,
  .admin-create-action {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .shared-projects-cell {
    min-width: 78px;
    gap: 6px;
  }

  .shared-project-count {
    min-width: 34px;
    height: 32px;
    padding: 0 10px;
  }

  .icon-action.shared-projects-button {
    width: 32px;
    height: 32px;
  }

  .shared-projects-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 86dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  .shared-projects-table-shell {
    height: min(50dvh, 340px);
  }

  .shared-projects-table {
    min-width: 460px;
  }

  .shared-projects-table th,
  .shared-projects-table td {
    padding: 12px;
  }

  .project-card-bottombar {
    justify-content: space-between;
    padding: 10px 12px;
  }

  .project-card-bottombar .icon-action {
    flex: 1 1 40px;
    min-width: 40px;
    max-width: 48px;
  }

  .viewer-body {
    display: block;
    padding-top: 0;
  }

  .viewer-header {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: var(--page-gutter);
    right: var(--page-gutter);
    z-index: 18;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 251, 247, 0.84);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(68, 47, 37, 0.14);
  }

  .viewer-header h1 {
    font-size: clamp(1rem, 4.2vw, 1.25rem);
    line-height: 1.1;
    margin-bottom: 2px;
  }

  .viewer-header .eyebrow {
    margin-bottom: 2px;
    letter-spacing: 0.12em;
    font-size: 0.62rem;
  }

  .viewer-header .muted {
    font-size: 0.72rem;
    line-height: 1.2;
    margin-bottom: 0;
  }

  .viewer-topbar {
    gap: 8px;
  }

  .viewer-topbar .inline-actions,
  .viewer-topbar .viewer-link-button {
    width: auto;
  }

  .viewer-link-button {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .viewer-icon-link {
    width: 34px;
    min-width: 34px;
    padding: 0;
  }

  .viewer-icon-link .material-icons {
    font-size: 19px;
  }

  .viewer-toolbar {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translateX(-50%);
    width: min(calc(100vw - (var(--page-gutter) * 2)), 360px);
    max-width: none;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 18px;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .viewer-tool {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
  }

  .viewer-tool .material-icons {
    font-size: 18px;
  }

  .viewer-toolbar-handle {
    display: inline-flex;
  }

  .viewer-toolbar.is-dragging {
    box-shadow: 0 18px 34px rgba(68, 47, 37, 0.22);
  }

  .viewer-measure-readout {
    min-width: 0;
    max-width: 110px;
    padding: 0 0 0 2px;
    font-size: 0.74rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 1 110px;
  }

  .viewer-canvas {
    min-height: calc(var(--viewer-vh) * 100);
    height: calc(var(--viewer-vh) * 100);
    width: 100%;
    margin: 0;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }

  .viewer-canvas-full {
    height: calc(var(--viewer-vh) * 100);
  }

  .viewer-error {
    position: fixed;
    left: var(--page-gutter);
    right: var(--page-gutter);
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 17;
    padding: 0;
  }

  .panel-detail-dialog {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)) 12px;
  }

  .panel-detail-resize-handle {
    display: none;
  }

  .panel-detail-header {
    align-items: flex-start;
  }

  .panel-detail-header > div {
    min-width: 0;
  }

  .panel-detail-close {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  .panel-detail-tools {
    gap: 6px;
  }

  .panel-detail-tool {
    width: 34px;
    height: 34px;
  }

  .panel-detail-zoom {
    flex: 1 1 auto;
    text-align: left;
  }

  .panel-detail-canvas-wrap {
    border-radius: 10px;
  }

  .panel-detail-cuts {
    font-size: 0.86rem;
  }
}
