#materials {
  --work-paper: var(--folio-paper, #f5f3ed);
  --work-ink: var(--folio-ink, #20211e);
  --work-blue: var(--folio-accent, #284cbd);
  --work-line: color-mix(in srgb, var(--work-ink) 26%, transparent);
  --work-muted: color-mix(in srgb, var(--work-ink) 75%, var(--work-paper));
  padding-block: clamp(50px, 7vw, 106px) clamp(38px, 5vw, 76px);
  scroll-margin-top: var(--site-bar-height, 70px);
  color: var(--work-ink);
}
.atlas-home #materials { padding-top: clamp(28px,3vw,54px); }
#materials:focus { outline: none; }
.material-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding-bottom: clamp(19px, 2.6vw, 38px); }
.material-heading .mat-heading-title {
  display: grid; gap: 12px; min-width: 0; margin: 0;
  font: 400 clamp(55px, 8vw, 128px)/.93 var(--folio-serif, "Baskerville", "Times New Roman", serif);
  letter-spacing: -.065em;
}
#materialDisplayTitle em { font-weight: 400; letter-spacing: -.06em; }
.mat-heading-label { display: flex; align-items: baseline; gap: 7px; font: 600 13px/1.4 -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: .025em; }
.material-heading .title-count { padding: 0; font: 500 11px/1.2 ui-monospace, monospace; color: var(--work-muted); letter-spacing: -.025em; }
.material-heading .title-count:not(:empty)::before, .mat-filters .view-count:not([hidden])::before { content: "("; }
.material-heading .title-count:not(:empty)::after, .mat-filters .view-count:not([hidden])::after { content: ")"; }
.material-tools { display: flex; align-items: center; gap: 14px; }
.material-tools .search-box { align-items: center; max-width: 210px; padding: 0 3px; border: 0; border-bottom: 1px solid var(--work-line); border-radius: 0; background: transparent; }
.material-tools .search-box:focus-within { border-color: var(--work-blue); box-shadow: none; }
.mat-button, .mat-icon, .text-control { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.mat-button { min-height: 43px; padding: 0 18px; border-radius: 26px; font-size: 14px; font-weight: 610; text-decoration: none; white-space: nowrap; }
.mat-button .icon { width: 17px; height: 17px; }
.mat-button.primary { background: #23292c; color: white; }
.mat-button.primary:hover { background: #394246; }
.mat-button.secondary { color: #303539; background: #eceeec; }
.mat-icon { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #eceeec; color: #34393c; }
.mat-icon .icon { width: 17px; height: 17px; }
button:disabled { cursor: default; opacity: .5; }
#materials .mat-button.primary { background: var(--work-ink); color: var(--work-paper); }
.mat-presentation { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding-block: 7px; border-block: 1px solid var(--work-line); }
.mat-layout, .mat-filters, .mat-transport, .mat-project-actions, .mat-project-tools { display: flex; align-items: center; }
.mat-layout, .mat-filters { gap: clamp(10px, 1.6vw, 26px); }
.mat-layout button, .mat-filters button {
  position: relative; display: inline-flex; align-items: center; gap: 5px;
  min-height: 42px; color: var(--work-muted); font-size: 13px; font-weight: 500;
}
.mat-layout button { gap: 7px; font-size: 15px; letter-spacing: -.04em; }
.mat-layout button[aria-pressed="true"], .mat-filters button[aria-pressed="true"] { color: var(--work-blue); }
.mat-filters button[aria-pressed="true"]::after { position: absolute; content: ""; right: 0; bottom: 6px; left: 0; border-top: 1px solid currentColor; }
.mat-filters button:disabled { opacity: .69; }
.mat-filters .view-count { font: 500 10px/1 ui-monospace, monospace; }
.layout-orbit { width: 16px; height: 9px; border: 1.5px solid currentColor; border-radius: 100%; transform: rotate(-26deg); }
.layout-index { width: 13px; height: 9px; border-block: 1.5px solid currentColor; background: linear-gradient(currentColor,currentColor) center / 100% 1px no-repeat; }
#materials #addMaterial { padding-inline: 2px; border-bottom: 1px solid var(--work-ink); border-radius: 0; color: var(--work-ink); background: transparent; }
.mat-orbit-stage { position: relative; }
.mat-orbit-hint { position: absolute; right: 1px; bottom: 5px; margin: 0; color: var(--work-muted); font: 500 11px/1.4 -apple-system, BlinkMacSystemFont, sans-serif; pointer-events: none; }
.mat-orbit-hint span { margin-right: 3px; color: var(--work-blue); }
.mat-grid { position: relative; min-width: 0; overflow-anchor: none; }
.mat-grid[data-layout="orbit"] {
  isolation: isolate; display: grid; grid-template-columns: minmax(0,1fr); place-items: center;
  padding-block: clamp(58px, 7.5vw, 115px) clamp(33px, 3.8vw, 64px); overflow: hidden;
  touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none;
}
/* WebKit resolves gesture actions from the hit surface, including transformed
   buttons. The video and its overlays delegate hits to their single button. */
.mat-grid[data-layout="orbit"] :is(.mat-tile,.mat-tile-open,.mat-visual) { touch-action: pan-y pinch-zoom; }
@media (any-pointer: coarse) {
  .mat-grid[data-layout="orbit"] .mat-visual { pointer-events: none; }
}
.mat-grid[data-layout="orbit"]:has(.mat-tile:nth-child(2)) { cursor: grab; }
.mat-grid[data-layout="orbit"]::before {
  position: absolute; z-index: 0; content: ""; top: 17%; bottom: 19%; left: 4%; right: 4%;
  border: 1px solid color-mix(in srgb, var(--work-ink) 14%, transparent); border-radius: 50%; transform: rotate(-5deg);
}
.mat-grid[data-layout="orbit"] .mat-tile {
  grid-area: 1/1; z-index: var(--orbit-layer, 1); width: min(56%, 790px);
  transform: var(--orbit-transform); transform-origin: center; backface-visibility: hidden;
}
.mat-grid[data-layout="orbit"] .mat-tile[data-distant="true"] { visibility: hidden; }
.mat-grid[data-layout="orbit"] .mat-tile-open { box-shadow: 0 7px 18px #1b190d1a; }
.mat-grid[data-layout="orbit"] .mat-tile:not([data-active]) .mat-tile-open { cursor: grab; }
.mat-grid[data-layout="orbit"][data-dragging], .mat-grid[data-layout="orbit"][data-dragging] .mat-tile-open { cursor: grabbing; }
.mat-grid[data-layout="orbit"] :is(.mat-caption,.mat-card-actions) { display: none; }
.mat-tile { position: relative; min-width: 0; }
.mat-tile-open { display: block; width: 100%; border-radius: 4px; text-align: left; }
.mat-visual { position: relative; isolation: isolate; display: grid; place-items: center; overflow: hidden; width: 100%; aspect-ratio: 16/9; border-radius: 4px; background: #1c1e1c; color: #fff; }
.mat-visual video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.mat-play { display: grid; place-items: center; position: absolute; bottom: 12px; left: 12px; width: 32px; height: 32px; border-radius: 50%; background: #14151382; border: 1px solid #ffffff80; }
.mat-play .icon { width: 14px; height: 14px; fill: currentColor; stroke-width: 1; }
.mat-caption { min-width: 0; }
.mat-caption strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; font-size: clamp(17px,2vw,31px); font-weight: 500; letter-spacing: -.035em; }
.mat-caption small, .mat-project-name p { display: block; margin: 5px 0 0; color: var(--work-muted); font-size: 12px; letter-spacing: .025em; }
.mat-card-actions, .mat-project-actions { display: flex; flex: none; gap: 1px; }
:is(.mat-card-actions,.mat-project-actions) button { display: grid; place-items: center; min-width: 40px; min-height: 42px; border-radius: 50%; color: var(--work-muted); }
:is(.mat-card-actions,.mat-project-actions) .icon { width: 17px; }
:is(.mat-card-actions,.mat-project-actions) [aria-pressed="true"] { color: var(--work-blue); }
:is(.mat-card-actions,.mat-project-actions) [aria-pressed="true"] .icon { fill: currentColor; }
:is(.mat-card-actions,.mat-project-actions) .mat-recover { width: auto; padding-inline: 8px; border-radius: 5px; font-size: 13px; }
.mat-project {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px clamp(12px, 3.5vw, 56px);
  padding: clamp(17px, 2vw, 29px) 0; border-block: 1px solid var(--work-line);
}
.mat-project-name { min-width: 0; }
.mat-project-name h3 { margin: 0; color: var(--work-ink); font-size: clamp(20px, 2.5vw, 40px); line-height: 1.1; font-weight: 520; letter-spacing: -.05em; overflow-wrap: anywhere; }
.mat-project-tools { gap: clamp(5px, 1.5vw, 21px); }
.mat-detail-link { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; font-weight: 590; font-size: 13px; white-space: nowrap; }
.mat-detail-link [aria-hidden] { color: var(--work-blue); }
.mat-transport { justify-content: space-between; gap: 8px; }
.mat-transport button { min-width: 40px; min-height: 42px; font-size: 24px; font-weight: 400; line-height: 1; }
.mat-transport output { font: 500 11px/1 ui-monospace, monospace; color: var(--work-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mat-grid[data-layout="index"] { display: grid; grid-template-columns: minmax(0,1fr); counter-reset: work-index; }
.mat-grid[data-layout="index"] .mat-tile { counter-increment: work-index; display: flex; align-items: center; gap: clamp(8px, 2vw,28px); padding: clamp(10px,1.3vw,20px) 2px; border-bottom: 1px solid var(--work-line); }
.mat-grid[data-layout="index"] .mat-tile::before { content: counter(work-index,decimal-leading-zero); color: var(--work-muted); font: 500 11px/1 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.mat-grid[data-layout="index"] .mat-tile-open { display: grid; grid-template-columns: clamp(76px,11vw,170px) minmax(0,1fr); align-items: center; gap: clamp(12px,2vw,32px); flex: 1; min-width: 0; }
.mat-grid[data-layout="index"] .mat-play { bottom: 4px; left: 4px; width: 21px; height: 21px; }
.mat-grid[data-layout="index"] .mat-play .icon { width: 9px; height: 9px; }
.mat-empty {
  position: relative; display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); align-items: center; justify-content: center;
  gap: clamp(24px, 6vw, 90px); min-height: clamp(280px, 29vw, 420px); padding: clamp(25px, 4.5vw, 76px) clamp(16px, 6vw, 100px); border-bottom: 1px solid var(--work-line);
}
.mat-empty > p { grid-column: 1/-1; justify-self: center; }
.mat-empty.dragging, .file-zone.dragging { outline: 2px solid var(--work-blue,#284cbd); outline-offset: -2px; background: #eef0f5; }
.mat-empty h3 { margin: 0 0 8px; color: var(--work-ink); font-size: clamp(22px,2.3vw,34px); line-height: 1.3; letter-spacing: -.045em; font-weight: 550; }
.mat-empty p { margin: 0; color: var(--work-muted); font-size: 14px; line-height: 1.65; }
.mat-empty .mat-button { min-height: 42px; margin-top: 12px; padding: 0; border-radius: 0; color: var(--work-blue); background: transparent; text-decoration: underline; text-underline-offset: .26em; }
.mat-empty .mat-button::after { content: "↗"; text-decoration: none; }
.empty-mark { position: relative; justify-self: center; width: min(100%, 430px); aspect-ratio: 2.1; color: var(--work-ink); }
.empty-mark i, .empty-mark::before, .empty-mark::after { position: absolute; content: ""; inset: 17% 4%; border: 1px solid currentColor; border-radius: 50%; }
.empty-mark::before { transform: rotate(-18deg); }
.empty-mark::after { transform: rotate(12deg); opacity: .38; }
.empty-mark i { transform: rotate(-1deg); opacity: .65; }
.empty-mark b { position: absolute; z-index: 1; top: 24%; right: 14%; width: clamp(10px,1.1vw,17px); aspect-ratio: 1; border-radius: 50%; background: var(--work-blue); }
#materialList[data-layout="index"] .mat-empty { display: flex; min-height: 235px; text-align: center; }
#materialList[data-layout="index"] .empty-mark { display: none; }
@media (hover:hover) {
  .mat-layout button:hover, .mat-filters button:hover:not(:disabled), .mat-transport button:hover, .mat-detail-link:hover, :is(.mat-card-actions,.mat-project-actions) button:hover { color: var(--work-blue); }
  .mat-tile-open:hover .mat-caption strong { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .15em; }
}
.mat-dialog { position: fixed; margin: auto; padding: 0; border: 1px solid #d5d9d8; border-radius: 25px; background: #fafaf8; color: var(--ink); max-height: calc(100dvh - 42px); overflow: auto; overscroll-behavior: contain; box-shadow: 0 28px 100px #141c2638; }
.mat-dialog::backdrop { background: #21282e61; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
body:has(.mat-dialog[open]) { overflow: hidden; }
.upload-dialog { width: min(540px,calc(100% - 36px)); }
.dialog-bar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 19px 25px 15px; border-bottom: 1px solid var(--line); }
.dialog-bar h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.04em; }
.upload-fields { padding: 20px 25px 0; }
.file-zone { position: relative; display: flex; align-items: center; justify-content: center; gap: 13px; min-height: 95px; padding: 12px; border: 1px dashed #adb8bb; border-radius: 15px; background: #f0f3f1; cursor: pointer; }
.file-zone:focus-within { outline: 2px solid #176ed2; outline-offset: 2px; }
.file-zone > input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-zone > .icon { width: 23px; height: 23px; color: #47565c; }
.file-zone span { min-width: 0; }
.file-zone strong, .file-zone small { display: block; overflow-wrap: anywhere; }
.file-zone strong { font-size: 15px; font-weight: 620; }
.file-zone small { margin-top: 4px; font-size: 12px; line-height: 1.6; color: #546067; }
.field-label { display: block; margin: 17px 0 7px; font-weight: 620; font-size: 14px; }
.mat-input { display: block; width: 100%; padding: 10px 12px; border: 1px solid #cdd2cf; border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; line-height: 1.5; }
textarea.mat-input { resize: vertical; min-height: 105px; max-height: 32dvh; }
.upload-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 19px 25px 22px; }
.upload-progress { margin-top: 14px; color: #46555a; font-size: 12px; }
.upload-progress progress { display: block; width: 100%; height: 7px; margin-bottom: 5px; accent-color: #455b61; }
.form-error { margin: 12px 0 0; color: #973a2b; font-size: 14px; }
.detail-dialog { width: min(1180px,calc(100% - 52px)); }
.detail-content { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(250px,1fr); }
.detail-media { position: relative; display: grid; place-items: center; align-self: stretch; min-height: 300px; background: #14181c; }
.detail-media video { display: block; width: 100%; height: min(59dvh,530px); object-fit: contain; }
.detail-media p { position: absolute; left: 12px; right: 12px; bottom: 46px; padding: 10px; color: #fff; background: #222c; border-radius: 9px; text-align: center; font-size: 13px; }
.detail-prompt { min-width: 0; padding: 17px 24px 21px; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prompt-head h3 { margin: 0; font-size: 15px; font-weight: 640; }
.text-control { min-height: 40px; border-radius: 10px; color: #43565d; padding-inline: 7px; font-size: 13px; }
.text-control .icon { width: 15px; height: 15px; }
.detail-prompt pre { margin: 9px 0 0; max-height: min(49dvh,440px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 15px; line-height: 1.8; color: #32383b; }
.detail-prompt pre::selection { background: #cbdde2; }
.materials-page .undo-notice { z-index: 13; }
@media (max-width:700px) {
  .detail-dialog { width: min(540px,calc(100% - 16px)); }
  .detail-content { grid-template-columns: minmax(0,1fr); }
  .detail-media { min-height: 0; }
  .detail-media video { height: auto; min-height: 110px; max-height: 39dvh; aspect-ratio: 16/10; }
  .detail-prompt { padding: 12px 17px 20px; }
  .detail-prompt pre { max-height: 29dvh; }
}
@media (max-width:650px) {
  #materials { padding-block: 44px 32px; }
  .material-heading { display: grid; gap: 20px; padding-bottom: 16px; }
  .material-tools { gap: 12px; }
  .material-tools .search-box { flex: 1; width: auto; max-width: none; min-width: 0; }
  .material-tools .mat-button { min-height: 41px; padding-inline: 14px; }
  .mat-presentation { gap: 2px 12px; }
  .mat-layout, .mat-filters { gap: 11px; }
  .mat-layout button { font-size: 13px; gap: 4px; }
  .mat-filters button { font-size: 12px; gap: 2px; }
  .mat-grid[data-layout="orbit"] { padding-block: 48px 30px; }
  .mat-grid[data-layout="orbit"] .mat-tile { width: 67%; }
  .mat-project { grid-template-columns: minmax(0,1fr) auto; gap: 6px 10px; }
  .mat-project-tools { grid-column: 1/-1; grid-row: 2; justify-content: space-between; }
  .mat-transport { grid-column: 2; grid-row: 1; gap: 2px; }
  .mat-transport button { min-width: 34px; }
  .mat-grid[data-layout="index"] .mat-tile { gap: 8px; }
  .mat-grid[data-layout="index"] .mat-tile::before { display: none; }
  .mat-card-actions button { min-width: 32px; }
  .mat-empty { grid-template-columns: minmax(0,1fr); gap: 10px; padding: 20px 8px 24px; text-align: center; }
  .empty-mark { width: min(62%,230px); }
  .mat-empty .mat-button { margin-top: 5px; }
  .mat-dialog { max-height: calc(100dvh - 14px - env(safe-area-inset-top)); border-radius: 21px; }
  .upload-dialog { width: calc(100% - 16px); }
  .dialog-bar { padding: 13px 16px 10px; }
  .dialog-bar h2 { font-size: 20px; }
  .upload-fields { padding: 14px 16px 0; }
  .upload-actions { padding: 15px 16px max(15px,env(safe-area-inset-bottom)); }
}

.materials-page .undo-notice { bottom: max(20px, env(safe-area-inset-bottom)); }

.mat-order-trigger { min-height: 42px; border-bottom: 1px solid currentColor; font-size: 14px; font-weight: 550; white-space: nowrap; }
.detail-dialog:not(:has(#detailPrompt:not([hidden]))) .detail-content { grid-template-columns: minmax(0,1fr); }
.detail-dialog:not(:has(#detailPrompt:not([hidden]))) .detail-media video { height: min(70dvh,700px); }
.order-dialog { width: min(570px,calc(100% - 24px)); }
.order-fields { display: grid; grid-template-columns: minmax(100px,1fr) minmax(64px,92px) auto; align-items: end; gap: 9px; padding: 20px 24px 12px; }
.order-fields label { display: grid; gap: 5px; min-width: 0; font-weight: 570; font-size: 13px; }
.order-fields :is(select,input) { min-width: 0; width: 100%; min-height: 43px; padding: 5px 8px; font: inherit; font-size: 16px; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.order-list { margin: 0 24px; padding: 0; list-style: none; max-height: min(36dvh,350px); overflow-y: auto; overscroll-behavior: contain; counter-reset: display-rank; border-block: 1px solid var(--line); }
.order-list li { counter-increment: display-rank; display: flex; align-items: baseline; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.order-list li:last-child { border: 0; }
.order-list li::before { content: counter(display-rank,decimal-leading-zero); flex: none; font: 500 11px/1.2 var(--folio-mono, monospace); color: var(--muted); }
.order-list [aria-current="true"] { color: var(--folio-accent); font-weight: 640; }
.order-status { margin: 8px 24px 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.order-status:empty { margin: 0; }
@media (max-width:650px) {
  .order-fields { padding: 16px 14px 10px; grid-template-columns: minmax(60px,1fr) 65px auto; gap: 7px; }
  .order-list { margin-inline: 14px; }
  .order-status { margin-inline: 14px; }
  .detail-dialog:not(:has(#detailPrompt:not([hidden]))) .detail-media video { height: auto; min-height: 130px; max-height: 68dvh; }
}
