:root {
  --ink: #101211;
  --muted: #646560;
  --paper: #f3efe7;
  --white: #fffdf8;
  --panel: #e9e4da;
  --line: rgba(16, 18, 17, .2);
  --blue: #287be1;
  --red: #dc4d3b;
  --green: #1e7552;
  --sans: "Helvetica Neue", Helvetica, Arial, "Noto Sans SC", "Noto Sans JP", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.5;
}

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

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.kicker {
  margin: 0 0 12px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.kicker.red,
.quick-index.red { color: var(--red); }

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: var(--ink);
}

.login-card {
  width: min(680px, 100%);
  padding: clamp(34px, 6vw, 70px);
  background: var(--paper);
}

.login-card > img { width: 255px; margin-bottom: 70px; }

.login-card h1 {
  max-width: 560px;
  margin: 0 0 22px;
  font-size: clamp(42px, 6vw, 70px);
  font-weight: 450;
  letter-spacing: -.055em;
  line-height: .98;
}

.login-card > p:not(.kicker) { max-width: 520px; color: var(--muted); }

.login-card form { margin: 38px 0 28px; }

label > span,
.login-card label,
.upload-field > div > span {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.inline-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; }

input,
textarea,
select {
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 0;
}

textarea { resize: vertical; }

small { color: var(--muted); font-size: 12px; font-weight: 400; text-transform: none; }

.primary-button,
.secondary-button,
.quiet-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 11px 17px;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
}

.primary-button { color: var(--white); background: var(--ink); }
.secondary-button { color: var(--ink); background: transparent; }
.quiet-button { min-height: auto; padding: 5px 0; color: var(--muted); background: transparent; border: 0; border-bottom: 1px solid var(--line); }

.primary-button:hover,
.primary-button:focus-visible { color: var(--ink); background: var(--blue); border-color: var(--blue); }
.secondary-button:hover,
.secondary-button:focus-visible { color: var(--white); background: var(--ink); }
.primary-button:disabled { color: #a6a49e; background: #dad5cc; border-color: #dad5cc; cursor: not-allowed; }

.quiet-link { color: var(--muted); text-underline-offset: 4px; }
.quiet-link { display: inline-flex; gap: 8px; align-items: center; }
.icon-arrow-left {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("/static/icons/arrow-left.svg") center / contain no-repeat;
  mask: url("/static/icons/arrow-left.svg") center / contain no-repeat;
}
.form-message { min-height: 24px; margin: 10px 0 0; color: var(--red); font-size: 14px; }

.studio-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 260px minmax(0, 1fr);
}

.studio-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 34px 28px 28px;
  background: #dfdad0;
  border-right: 1px solid var(--line);
}

.studio-brand img { width: 185px; margin-bottom: 34px; }

.studio-nav { display: grid; margin-top: 36px; border-top: 1px solid var(--line); }

.studio-nav button {
  padding: 15px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}

.studio-nav button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.studio-nav button[aria-current="page"]::before { color: var(--blue); content: "+ "; }

.sidebar-foot { display: grid; gap: 20px; margin-top: auto; }
.save-state { color: var(--green); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.save-state.dirty { color: var(--red); }

.studio-main { min-width: 0; }

.studio-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 114px;
  align-items: center;
  gap: 28px;
  padding: 22px clamp(24px, 5vw, 72px);
  background: rgba(243, 239, 231, .96);
  border-bottom: 1px solid var(--line);
}

.studio-topbar h1 { margin: 0; font-size: 31px; font-weight: 500; letter-spacing: -.035em; }
.studio-topbar .kicker { margin-bottom: 3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.edit-language-control { display: flex; gap: 9px; align-items: center; margin-right: 4px; }
.edit-language-control > span { margin: 0; color: var(--muted); font-size: 9px; white-space: nowrap; }
.edit-language-control select { width: auto; min-width: 112px; padding: 11px 30px 11px 11px; background: transparent; }
.language-help { max-width: 142px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.mobile-nav-button { display: none; }

.conflict-banner {
  padding: 18px clamp(24px, 5vw, 72px);
  color: #571d16;
  background: #f2c9c1;
  border-bottom: 1px solid #b94332;
}
.conflict-banner button { margin-left: 18px; color: inherit; background: transparent; border: 0; text-decoration: underline; cursor: pointer; }

.studio-panel { padding: clamp(42px, 7vw, 96px) clamp(24px, 5vw, 72px) 100px; }

.welcome-block { max-width: 800px; }
.welcome-block h2,
.panel-heading h2 {
  margin: 0 0 18px;
  font-size: clamp(48px, 7vw, 90px);
  font-weight: 430;
  letter-spacing: -.06em;
  line-height: .96;
}
.welcome-block > p:last-child,
.panel-heading > div > p:last-child { max-width: 630px; color: var(--muted); font-size: 18px; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 64px;
  border-top: 1px solid var(--line);
}

.quick-action {
  display: grid;
  min-height: 245px;
  align-content: start;
  gap: 18px;
  padding: 30px 36px 34px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}
.quick-action:nth-child(even) { padding-right: 0; padding-left: 36px; border-left: 1px solid var(--line); }
.quick-action:nth-child(n+3) { border-top: 0; }
.quick-action:hover { background: var(--white); }
.quick-index { color: var(--blue); font-family: var(--mono); font-size: 11px; }
.quick-action strong { max-width: 420px; font-size: clamp(30px, 3vw, 45px); font-weight: 500; letter-spacing: -.045em; line-height: 1.05; }
.quick-action > span:last-child { max-width: 430px; color: var(--muted); }

.count-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 70px; border-top: 1px solid var(--line); }
.count-item { padding: 18px 0; border-bottom: 1px solid var(--line); }
.count-item + .count-item { padding-left: 24px; border-left: 1px solid var(--line); }
.count-item strong { display: block; font-size: 30px; font-weight: 500; }
.count-item span { color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }

.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 48px; }
.panel-heading h2 { font-size: clamp(52px, 6vw, 80px); }

.doi-bar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 0;
  align-items: stretch;
  margin-bottom: 42px;
  padding: 22px;
  background: var(--panel);
}
.doi-bar label { align-self: center; margin-right: 14px; font-family: var(--mono); font-size: 11px; font-weight: 700; }
.doi-bar [data-doi-status] { grid-column: 2 / -1; min-height: 0; margin-top: 7px; color: var(--muted); font-size: 13px; }

.content-list { border-top: 1px solid var(--line); }
.content-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 30px;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.content-item-copy { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 18px; align-items: start; }
.content-item img { width: 62px; height: 62px; object-fit: cover; }
.item-placeholder { display: grid; width: 62px; height: 62px; place-items: center; color: var(--blue); background: var(--panel); font-family: var(--mono); font-size: 10px; }
.content-item h3 { margin: 0 0 7px; font-size: clamp(19px, 2vw, 27px); font-weight: 520; letter-spacing: -.025em; line-height: 1.15; }
.content-item p { margin: 0; color: var(--muted); font-size: 13px; }
.item-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.item-badge { padding: 3px 6px; color: var(--blue); border: 1px solid rgba(40,123,225,.45); font-family: var(--mono); font-size: 9px; text-transform: uppercase; }
.item-badge.red { color: var(--red); border-color: rgba(220,77,59,.45); }
.item-actions { display: flex; gap: 10px; align-items: center; }
.item-actions button { color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.item-actions button[data-delete] { color: #a93225; }
.item-move-group { display: flex; gap: 4px; margin-right: 4px; }
.item-move-btn { padding: 2px 6px; font-size: 13px; line-height: 1; border-bottom: 1px solid var(--line); }
.item-move-btn:hover { color: var(--blue); border-color: var(--blue); }

.life-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 46px 54px; }
.editor-section { min-width: 0; }
.editor-section-heading { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between; min-height: 72px; margin-bottom: 18px; }
.editor-section-heading h3 { margin: 0; font-size: clamp(27px, 3vw, 38px); font-weight: 480; letter-spacing: -.04em; line-height: 1; }
.editor-section-heading .kicker { margin-bottom: 6px; }
.editor-section-heading .secondary-button { flex: 0 0 auto; }
.compact-list .content-item { gap: 18px; padding: 18px 0; }
.compact-list .content-item-copy { grid-template-columns: 48px minmax(0, 1fr); gap: 12px; }
.compact-list .content-item img,
.compact-list .item-placeholder { width: 48px; height: 48px; }
.compact-list .item-actions { gap: 8px; }
.skills-form { display: grid; gap: 14px; padding-top: 18px; border-top: 1px solid var(--line); }
.skills-form .primary-button { justify-self: end; }

.profile-form,
.editor-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; max-width: 940px; }
.profile-form label,
.editor-form label { min-width: 0; }
.profile-form .wide,
.editor-form .wide,
.dialog-heading { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.inline-save-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.publish-now-button { min-width: 124px; }

.toggle-field {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--panel);
  border-left: 3px solid var(--blue);
}
.toggle-field input { width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--blue); }
.toggle-field > span { margin: 0; font-family: var(--sans); font-size: 14px; letter-spacing: 0; text-transform: none; }

.editor-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
}
.editor-dialog::backdrop { background: rgba(7, 8, 8, .82); }
.dialog-close-row { position: sticky; z-index: 2; top: 0; display: flex; justify-content: flex-end; padding: 12px 20px 0; background: var(--paper); }
.dialog-close-row button { color: var(--muted); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.editor-form { padding: 20px clamp(22px, 5vw, 64px) 56px; }
.dialog-heading { margin-bottom: 12px; }
.dialog-heading h2 { margin: 0 0 12px; font-size: clamp(42px, 6vw, 72px); font-weight: 450; letter-spacing: -.055em; line-height: 1; }
.dialog-heading > p:last-child { color: var(--muted); }

.upload-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 22px;
  align-items: center;
  padding: 18px;
  background: var(--panel);
}
.upload-field small { display: block; }

.link-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
}
.link-editor small { display: block; }
.link-preview-list { display: flex; flex-direction: column; gap: 6px; }
.link-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--white, #fff);
  border: 1px solid var(--line, rgba(0,0,0,.12));
}
.link-preview-item .link-preview-label { font-weight: 600; white-space: nowrap; }
.link-preview-item .link-preview-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.link-preview-item button { flex-shrink: 0; padding: 4px 7px; color: var(--white); background: rgba(16,18,17,.88); border: 0; font-size: 10px; cursor: pointer; }
.link-input-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; }
.file-button { position: relative; overflow: hidden; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.crop-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 15px;
  min-width: 0;
  padding-top: 4px;
}

.crop-frame {
  width: min(100%, 720px);
  overflow: hidden;
  background: #d7d1c6;
  border: 1px solid var(--line);
}

.crop-frame-wide,
.crop-frame-award { aspect-ratio: 16 / 9; }
.crop-frame-life { aspect-ratio: 4 / 3; }
.crop-frame-project { width: min(100%, 720px); aspect-ratio: 4 / 3; }

.crop-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crop-sliders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  max-width: 720px;
}

.crop-sliders label > span { margin-bottom: 5px; }
.crop-sliders input[type="range"] {
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  accent-color: var(--blue);
  cursor: ew-resize;
}

.crop-sliders label:last-child input[type="range"] { cursor: ns-resize; }
.publish-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  max-width: 720px;
  margin: 0;
  padding: 11px 13px;
  color: var(--ink);
  background: rgba(17, 91, 206, .08);
  border-left: 3px solid var(--blue);
  font-size: 11px;
  line-height: 1.45;
}
.publish-steps strong { font-weight: 650; }
.publish-steps span { color: var(--blue); }
.photo-preview-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.photo-preview-item { position: relative; min-width: 0; }
.photo-preview-grid img { width: 100%; height: 100px; object-fit: cover; }
.photo-preview-grid video { width: 100%; height: 140px; object-fit: cover; background: #000; }
.photo-preview-item.cover-photo::before {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 3px 6px;
  color: var(--white);
  background: var(--blue);
  content: "Cover";
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.photo-preview-item button {
  position: absolute;
  bottom: 4px;
  padding: 4px 7px;
  color: var(--white);
  background: rgba(16,18,17,.88);
  border: 0;
  font-size: 10px;
  cursor: pointer;
}
.photo-preview-item .photo-remove-btn { right: 4px; }
.photo-preview-item .photo-rotate-btn { left: 4px; }
.photo-preview-item .photo-rotate-btn:disabled { opacity: .5; cursor: wait; }
.photo-preview-item .photo-move-btn { top: 4px; bottom: auto; }
.photo-preview-item .photo-move-left { left: 4px; }
.photo-preview-item .photo-move-right { right: 4px; }
.photo-preview-item .photo-cover-btn {
  top: 4px;
  left: 50%;
  bottom: auto;
  transform: translateX(-50%);
  background: rgba(17, 91, 206, .92);
}

.studio-toast {
  position: fixed;
  z-index: 80;
  right: 20px;
  bottom: 20px;
  max-width: 390px;
  padding: 13px 17px;
  color: var(--white);
  background: var(--ink);
  border-left: 3px solid var(--blue);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.studio-toast.visible { opacity: 1; transform: translateY(0); }
.studio-toast.error { border-left-color: var(--red); }

@media (max-width: 900px) {
  .studio-shell { grid-template-columns: 1fr; }
  .studio-sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(310px, 88vw);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }
  .studio-sidebar.open { transform: translateX(0); box-shadow: 12px 0 40px rgba(0,0,0,.22); }
  .mobile-nav-button { display: inline-flex; padding: 8px 0; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
  .topbar-actions .secondary-button { display: none; }
  .quick-grid { grid-template-columns: 1fr; }
  .quick-action:nth-child(even) { padding-left: 0; border-left: 0; }
  .count-strip { grid-template-columns: repeat(2, 1fr); }
  .panel-heading { align-items: flex-start; }
  .life-editor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .login-shell { padding: 0; place-items: stretch; }
  .login-card { min-height: 100vh; padding: 36px 22px; }
  .login-card > img { margin-bottom: 68px; }
  .inline-field { grid-template-columns: 1fr; gap: 10px; }
  .studio-topbar { min-height: 92px; padding: 15px 18px; }
  .studio-topbar h1 { font-size: 24px; }
  .topbar-actions .primary-button { padding: 9px 12px; font-size: 13px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .publish-now-button { flex: 1 1 150px; }
  .language-help { display: none; }
  .edit-language-control { position: absolute; right: 18px; bottom: -49px; margin: 0; padding: 5px 8px; background: var(--paper); border: 1px solid var(--line); }
  .edit-language-control select { min-width: 92px; padding: 7px 26px 7px 8px; border: 0; }
  .studio-panel { padding-right: 18px; padding-left: 18px; }
  .panel-heading { display: grid; }
  .panel-heading .primary-button { justify-self: start; }
  .doi-bar { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .doi-bar [data-doi-status] { grid-column: 1; }
  .count-strip { grid-template-columns: 1fr 1fr; }
  .content-item { grid-template-columns: 1fr; }
  .item-actions { padding-left: 80px; }
  .profile-form,
  .editor-form { grid-template-columns: minmax(0, 1fr); }
  .profile-form .wide,
  .editor-form .wide,
  .dialog-heading { grid-column: 1; }
  .upload-field { grid-template-columns: 1fr; }
  .link-input-row { grid-template-columns: 1fr; }
  .crop-editor,
  .photo-preview-grid { grid-column: 1; }
  .crop-sliders { grid-template-columns: 1fr; gap: 8px; }
  .photo-preview-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-section-heading { display: grid; }
  .editor-section-heading .secondary-button { justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
