:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #111827;
  background: #f6f7f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.home-page {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  color: #10131a;
  background: #f5f6f8;
}

.home-page::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(246,247,249,.98) 0%, rgba(246,247,249,.76) 35%, rgba(246,247,249,.36) 68%, rgba(246,247,249,.92) 100%),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=2200&q=80");
  background-size: cover;
  background-position: center;
  filter: saturate(.9);
}

.home-page::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 0;
  height: 34vh;
  background: linear-gradient(to bottom, transparent, #f6f7f9 72%);
  pointer-events: none;
}

.home-nav {
  position: relative;
  z-index: 20;
  width: min(1180px, calc(100% - 48px));
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto;
  color: #10131a;
}

.home-brand,
.home-nav-actions,
.logo {
  display: inline-flex;
  align-items: center;
}

.home-brand,
.logo {
  gap: 10px;
  color: #10131a;
  font-size: 15px;
  font-weight: 850;
}

.home-brand {
  min-width: 42px;
  border: 0;
  background: transparent;
  padding: 0;
}

.home-brand-name {
  white-space: nowrap;
}

.home-brand-mark,
.logo span,
.auth-brand-icon,
.avatar {
  display: grid;
  place-items: center;
  color: white;
  background: #101417;
  font-weight: 900;
}

.home-brand-mark img,
.logo span img,
.auth-brand-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.home-brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}

.logo span {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  overflow: hidden;
}

.logo span img {
  object-fit: contain;
}

.home-nav-actions {
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(17,24,39,.12);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(18px);
}

.home-nav-link {
  min-height: 40px;
  border: 0;
  border-radius: 13px;
  padding: 0 17px;
  color: #5f6675;
  background: transparent;
  font-size: 14px;
  font-weight: 850;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.home-nav-link:hover,
.home-nav-link.active {
  color: white;
  background: #080b12;
  transform: translateY(-1px);
}

.home-login-link {
  min-height: 42px;
  border: 1px solid rgba(17,24,39,.12);
  border-radius: 999px;
  padding: 0 18px;
  color: #10131a;
  background: rgba(255,255,255,.82);
  font-size: 14px;
  font-weight: 900;
  backdrop-filter: blur(16px);
}

.home-main {
  position: relative;
  z-index: 5;
  min-height: calc(100vh - 74px);
  display: grid;
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 54px;
}

.home-hero {
  width: min(720px, 100%);
  margin-left: clamp(40px, 8vw, 116px);
  padding: 0;
}

.home-kicker {
  margin: 0 0 18px;
  width: fit-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: #374151;
  background: transparent;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0;
}

.home-kicker::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 6px rgba(22,163,74,.12);
}

.home-hero h1 {
  margin: 0;
  color: #10131a;
  font-size: clamp(46px, 5.9vw, 82px);
  line-height: .98;
  letter-spacing: 0;
  font-weight: 900;
}

.home-copy {
  width: min(660px, 100%);
  margin: 24px 0 0;
  color: #4b5563;
  font-size: 18px;
  line-height: 1.75;
  font-weight: 650;
}

.home-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.home-primary,
.home-secondary {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  min-width: 126px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 900;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}

.home-primary {
  color: #fff;
  background: #080b12;
  box-shadow: 0 18px 42px rgba(16,20,23,.18);
}

.home-secondary {
  color: #10131a;
  background: rgba(255,255,255,.76);
  border: 1px solid rgba(16,20,23,.1);
  box-shadow: 0 12px 34px rgba(26,36,44,.07);
}

.home-primary:hover,
.home-secondary:hover {
  transform: translateY(-2px);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,.15);
}

.login-page {
  position: relative;
  z-index: 1;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: 42px 24px;
  background:
    linear-gradient(132deg, rgba(248,251,255,.98) 0%, rgba(242,246,249,.96) 48%, rgba(255,249,241,.95) 100%),
    #f6f7f9;
}

.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(16,20,23,.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(16,20,23,.04) 1px, transparent 1px),
    repeating-linear-gradient(118deg, transparent 0 54px, rgba(14,165,233,.05) 54px 55px);
  background-size: 64px 64px, 64px 64px, auto;
  mask-image: linear-gradient(to bottom, black, black 78%, transparent);
  pointer-events: none;
}

.login-page .auth-shell {
  position: relative;
  z-index: 1;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(320px, 560px) 400px;
  align-items: stretch;
  gap: 18px;
  width: min(1000px, 96vw);
}

.auth-cover,
.auth-card,
.mode-panel,
.tool-panel,
.result-panel,
.profile-head,
.profile-note,
.stats div,
.admin-panel {
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(17,24,39,.08);
  box-shadow: 0 18px 54px rgba(17,24,39,.07);
}

.auth-cover {
  min-height: 560px;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 16px;
  color: #f8fafc;
  background:
    linear-gradient(140deg, rgba(17,18,20,.94), rgba(8,9,10,.88)),
    radial-gradient(circle at 86% 18%, rgba(255,255,255,.14), transparent 30%);
  box-shadow: 0 24px 80px rgba(0,0,0,.24);
}

.auth-cover-brand,
.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.auth-brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 12px;
}

.auth-cover h1,
.profile-head p,
.profile-note p {
  max-width: 620px;
}

.auth-cover h1,
.profile-head h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 86px);
  line-height: 1;
  letter-spacing: 0;
}

.auth-cover h1 {
  margin-top: 42px;
  color: #fff;
  font-size: clamp(38px, 5.2vw, 64px);
}

.auth-cover p {
  margin: 20px 0 0;
  color: rgba(255,255,255,.68);
  font-size: 16px;
  line-height: 1.75;
}

.auth-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 34px;
}

.auth-feature-grid div {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 13px;
  font-weight: 850;
}

.auth-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.auth-flow span {
  position: relative;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 13px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  font-weight: 850;
}

.profile-head p,
.profile-note p {
  color: #6b7280;
  font-size: 17px;
  line-height: 1.7;
}

.auth-card {
  border-radius: 16px;
  padding: 32px;
  display: grid;
  align-content: center;
  background: rgba(255,255,255,.96);
}

.auth-logo {
  color: #111214;
}

.auth-tabs {
  display: flex;
  margin-top: 30px;
  padding: 4px;
  border-radius: 14px;
  background: #f4f4f5;
}

.auth-tab {
  min-height: 36px;
  flex: 1;
  border: 0;
  border-radius: 10px;
  color: #111214;
  background: transparent;
  font-size: 13px;
  font-weight: 850;
}

.auth-tab.active {
  color: #fff;
  background: #111827;
  box-shadow: 0 8px 22px rgba(17,18,20,.08);
}

.auth-submit {
  margin-top: 2px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8b5cf6;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 { margin: 0; font-size: 28px; letter-spacing: 0; }
form { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 8px; }
label span { color: #374151; font-size: 14px; font-weight: 800; }

input,
textarea,
select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 15px 16px;
  outline: none;
  background: rgba(255,255,255,.95);
  color: #111827;
}

textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: #111827; box-shadow: 0 0 0 4px rgba(17,24,39,.08); }

.quantity-control {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: center;
}

.quantity-control input {
  min-height: 50px;
  text-align: center;
  font-weight: 900;
}

.quantity-control input::-webkit-outer-spin-button,
.quantity-control input::-webkit-inner-spin-button {
  margin: 0;
}

.quantity-button {
  min-height: 50px;
  border: 1px solid rgba(17,24,39,.1);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #111827;
  background: white;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.quantity-button:hover {
  background: #f3f4f6;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
  align-items: end;
}

.primary,
.secondary,
.download,
.text-button {
  min-height: 48px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  text-decoration: none;
}

.primary,
.download {
  border: 0;
  color: white;
  background: #111827;
}

.secondary {
  border: 1px solid rgba(17,24,39,.1);
  color: #111827;
  background: white;
}

.text-button {
  border: 0;
  color: #6b7280;
  background: transparent;
}

.primary:disabled,
.secondary:disabled { opacity: .65; cursor: wait; }
.wide { width: 100%; }

.error,
.notice {
  margin: 0;
  border-radius: 14px;
  padding: 12px 14px;
}

.error { color: #b42318; background: #fff1f0; border: 1px solid #ffd7d2; }
.notice { color: #374151; background: #f3f4f6; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 32px;
  background: rgba(245,245,247,.86);
  border-bottom: 1px solid rgba(17,24,39,.08);
  backdrop-filter: blur(18px);
}

.logo {
  justify-self: start;
  border: 0;
  background: transparent;
}

nav {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.75);
}

nav button {
  height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  color: #6b7280;
  background: transparent;
  font-weight: 800;
}

nav button.active {
  color: #111827;
  background: white;
  box-shadow: 0 8px 20px rgba(17,24,39,.08);
}

.topbar nav .nav-btn {
  padding: 0 18px;
}

.topbar nav [data-entry].active {
  color: #fff;
  background: #050608;
}

.userbox {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #4b5563;
  font-weight: 800;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: 999px;
  color: #111827;
  background: white;
}

.workspace,
.profile,
.admin {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 14px 22px;
  align-items: start;
}

.mode-panel,
.tool-panel,
.result-panel {
  border-radius: 14px;
  padding: 16px;
}

.mode-panel {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tool-panel {
  grid-column: 1;
  grid-row: 2;
}

.result-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: calc(100vh - 126px);
}

.mode-card {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 7px;
  text-align: left;
  color: #111827;
  background: transparent;
}

.mode-card span {
  width: 42px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #111827;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 900;
}

.mode-card small { color: #6b7280; line-height: 1.45; font-size: 12px; }
.mode-card.selected { border-color: rgba(17,24,39,.12); background: white; box-shadow: 0 16px 38px rgba(17,24,39,.08); }
.mode-card.selected span { color: white; background: #111827; }

.tool-panel { padding: 18px; }
.control-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.control-grid label small {
  margin-top: -2px;
  color: #8b95a1;
  font-size: 12px;
  line-height: 1.45;
}
.sidebar-controls {
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid rgba(17,24,39,.08);
}
.sidebar-section-title {
  margin: 0;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 900;
}
.model-pill {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-radius: 12px;
  padding: 0 13px;
  color: #111827;
  background: #f3f4f6;
  font-size: 13px;
  font-weight: 900;
}
.advanced-controls {
  display: grid;
  gap: 12px;
  border-top: 1px solid rgba(17,24,39,.08);
  padding-top: 12px;
}
.advanced-controls summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  color: #374151;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}
.advanced-controls summary::-webkit-details-marker {
  display: none;
}
.advanced-controls summary::after {
  content: "+";
  margin-left: auto;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
}
.advanced-controls[open] summary::after {
  content: "-";
}
.sidebar-controls label {
  gap: 7px;
}
.sidebar-controls select,
.sidebar-controls input {
  min-height: 46px;
  border-radius: 14px;
  padding: 12px 13px;
}
.sidebar-controls .quantity-control {
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 7px;
}
.sidebar-controls .quantity-control input,
.sidebar-controls .quantity-button {
  min-height: 46px;
  border-radius: 14px;
}
.submit-row { display: grid; grid-template-columns: 1fr; gap: 10px; }

.watermark-tools { display: grid; gap: 14px; }
.dropzone {
  min-height: 138px;
  border: 1px dashed #b7bec8;
  border-radius: 14px;
  display: grid;
  gap: 10px;
  place-items: center;
  overflow: hidden;
  background: #f9fafb;
  text-align: center;
  cursor: pointer;
}

.dropzone input { display: none; }
.dropzone span { display: grid; gap: 10px; padding: 24px 24px 0; color: #6b7280; }
.dropzone strong { color: #111827; }
.dropzone button { margin-bottom: 22px; }

.selection-stage {
  position: relative;
  min-height: 210px;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #111827;
  touch-action: none;
  user-select: none;
}

.selection-stage img {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  pointer-events: none;
}

.selection-rect {
  position: absolute;
  border: 2px solid #ffffff;
  background: rgba(139,92,246,.18);
  box-shadow: 0 0 0 9999px rgba(17,24,39,.36);
}

.image-actions,
.selection-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #6b7280;
  font-size: 13px;
}

.image-actions span,
.selection-actions span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reference-text {
  margin: 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.6;
}

.inline-toggle {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 12px;
  padding: 0 14px;
  background: #f7f7f8;
}

.inline-toggle input {
  width: 38px;
  height: 22px;
  accent-color: #111827;
}

.result-panel { display: grid; gap: 18px; }
.result-preview {
  min-height: calc(100vh - 246px);
  border-radius: 14px;
  display: grid;
  gap: 14px;
  align-content: center;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(17,24,39,.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17,24,39,.04) 1px, transparent 1px),
    #f9fafb;
  background-size: 28px 28px;
  border: 1px solid rgba(17,24,39,.08);
  padding: 18px;
}

.result-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid rgba(17,24,39,.08);
}

.result-card img {
  width: 100%;
  max-height: calc(100vh - 326px);
  object-fit: contain;
  background: #f3f4f6;
  border-radius: 10px;
}

.result-card video {
  width: 100%;
  max-height: calc(100vh - 306px);
  display: block;
  background: #111827;
  border-radius: 10px;
}

.text-result {
  margin: 0;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 10px;
  padding: 16px;
  color: #111827;
  background: #f9fafb;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.empty { color: #6b7280; padding: 24px; text-align: center; }
.tasks { display: grid; gap: 10px; }
.task-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tiny-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}
.task-list { display: grid; gap: 10px; }
.task-item {
  min-height: 48px;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: 12px;
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #374151;
  background: white;
}
.task-item b { color: #111827; white-space: nowrap; }
.muted { color: #9ca3af; }

.profile,
.admin { display: grid; gap: 22px; }
.profile-head {
  border-radius: 16px;
  padding: 34px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.avatar {
  width: 76px;
  height: 76px;
  border-radius: 24px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}
.stats div {
  min-height: 128px;
  border-radius: 16px;
  padding: 24px;
  display: grid;
  align-content: space-between;
}
.stats span { color: #6b7280; font-weight: 800; }
.stats strong { font-size: 25px; }
.profile-note { border-radius: 16px; padding: 28px; }
.admin-entry-panel {
  display: grid;
  align-items: start;
  gap: 12px;
}
.admin-entry-button {
  width: fit-content;
  min-width: 170px;
  padding: 0 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.admin-panel {
  border-radius: 16px;
  padding: 22px;
  display: grid;
  gap: 16px;
}
.admin-list { display: grid; gap: 10px; }
.admin-item {
  min-height: 48px;
  border: 1px solid rgba(17,24,39,.08);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  background: #fff;
}
.admin-item span,
.admin-item a { color: #6b7280; font-size: 13px; }

@media (max-width: 1180px) {
  .work-grid { grid-template-columns: minmax(330px, 380px) minmax(0, 1fr); }
  .result-panel { grid-column: 2; grid-row: 1 / span 2; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .home-nav {
    height: auto;
    min-height: 66px;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 0;
  }

  .home-main {
    width: min(100% - 28px, 1180px);
    min-height: calc(100vh - 96px);
    padding: 38px 0 42px;
  }

  .home-hero {
    margin-left: 0;
    padding-bottom: 40px;
  }

  .home-hero h1 {
    font-size: clamp(40px, 13vw, 78px);
  }

  .auth-shell,
  .work-grid,
  .stats,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    width: min(100%, 520px);
  }

  .auth-cover {
    display: none;
  }

  .auth-card {
    padding: 26px;
  }

  .topbar { grid-template-columns: 1fr; padding: 16px; }
  .logo, .userbox, nav { justify-self: center; }
  nav { flex-wrap: wrap; justify-content: center; }
  .work-grid { grid-template-columns: 1fr; }
  .mode-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-panel,
  .result-panel {
    grid-column: 1;
    grid-row: auto;
  }
  .result-panel {
    min-height: auto;
  }
  .result-preview {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .overlay,
  .login-page { padding: 12px; }
  .home-nav {
    width: min(100% - 24px, 1180px);
  }
  .home-nav-actions {
    order: 3;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }
  .home-nav-link { padding: 0 10px; white-space: nowrap; }
  .home-actions { align-items: stretch; flex-direction: column; }
  .home-primary, .home-secondary { width: 100%; }
  .workspace, .profile, .admin { width: min(100% - 24px, 1440px); padding-top: 24px; }
  .mode-panel, .result-actions, .code-row, .submit-row { grid-template-columns: 1fr; }
  .tool-panel, .result-panel, .profile-head, .profile-note, .auth-card { padding: 20px; }
}
