/*
  Responsive composition layer. This intentionally follows the existing premium
  UI rules so the shared HTML and application flow can adapt without device
  detection or duplicate mobile markup.
*/
:root {
  --page-gutter: clamp(14px, 3.5vw, 28px);
  --panel-padding: clamp(20px, 4vw, 38px);
  --control-height: 48px;
}

html { min-width: 0; }
body { min-width: 0; }
img, svg { max-inline-size: 100%; }
button, input, select, textarea { max-inline-size: 100%; }

main,
#appView,
.shell-content,
.auth-shell,
.auth-brand,
.auth-form-area,
.auth-form-inner,
.section-grid > *,
.mode-grid > *,
.details-grid > *,
.result-layout > *,
.project-main,
.project-info,
.rights-text { min-width: 0; }

main { padding-inline: var(--page-gutter); }
.field input,
.field select { min-height: var(--control-height); }
.btn { min-height: 44px; }
.field input,
.field select,
.hint,
.project-meta,
.processing-copy-text,
.rights-copy { overflow-wrap: anywhere; }

/* Authentication: a compact editorial introduction followed by a full-width form. */
body.auth-state main {
  max-width: 1440px;
  padding: max(14px, env(safe-area-inset-top)) var(--page-gutter)
    max(28px, env(safe-area-inset-bottom));
}

#authView.auth-shell {
  width: min(100%, 1280px);
  min-height: 0;
  margin: clamp(14px, 3vw, 34px) auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-radius: clamp(16px, 3vw, 24px);
}

.auth-brand {
  min-height: 0;
  min-block-size: clamp(300px, 62svh, 430px);
  padding: clamp(24px, 7vw, 48px) clamp(20px, 7vw, 56px);
  gap: 28px;
}

.auth-brand:before { background-size: min(62%, 360px); }
.auth-brand:after {
  width: min(78vw, 440px);
  height: min(78vw, 440px);
  right: -42vw;
  bottom: -48vw;
}
.auth-brand-main { margin: auto 0; }
.auth-brand-title {
  font-size: clamp(2.15rem, 9.5vw, 3.25rem);
  line-height: 1.02;
}
.auth-brand-copy { font-size: clamp(.8rem, 3.6vw, .9rem); }
.auth-form-area { padding: clamp(28px, 7vw, 52px) clamp(20px, 6vw, 48px); }
.auth-form-inner { max-width: 430px; }
.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: clamp(24px, 6vw, 40px);
}
.tabs button {
  width: 100%;
  min-height: 44px;
  padding-inline: 8px;
  line-height: 1.2;
}
.auth-title { font-size: clamp(2rem, 8vw, 2.45rem); }
.auth-form-area .field { margin-block: 16px; }
.auth-form-area .field input { font-size: max(16px, 1rem); }

/* Compact application shell: navigation is a usable horizontal strip, not a squeezed sidebar. */
#appView {
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(14px, 3vw, 24px);
}
.shell-nav {
  min-height: 0;
  position: sticky;
  top: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}
.shell-brand { padding: 0 4px; }
.shell-brand span { display: none; }
.shell-nav-section,
.shell-nav-spacer,
.shell-user small,
.shell-user strong { display: none; }
.shell-nav nav {
  min-width: 0;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
}
.shell-nav nav::-webkit-scrollbar { display: none; }
.shell-nav a { flex: 0 0 auto; margin: 0; padding: 10px 9px; }
.shell-user { border: 0; margin: 0; padding: 0; }
.shell-user button { width: auto; margin: 0; padding-inline: 10px; }

.site-header { padding-inline: max(16px, env(safe-area-inset-left)); }
.site-header-context {
  min-width: 0;
  max-width: 48vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shared workspace modules use available width rather than fixed desktop proportions. */
.topbar { padding: var(--panel-padding); }
.topbar h2 { font-size: clamp(2rem, 7vw, 2.45rem); }
.flow { padding-inline: clamp(18px, 4vw, 34px); }
.step-card,
.progress-card,
.project-card,
.projects-panel,
.preview-panel { padding: var(--panel-padding); }
.mode-grid,
.section-grid,
.details-grid,
.format-grid,
.style-grid,
.advanced-grid,
.progress-wrap,
.result-layout { grid-template-columns: minmax(0, 1fr); }
.mode-card,
.format-option { min-height: 0; }
.color-entry { flex-wrap: wrap; }
.color-entry input { min-width: min(100%, 12rem); }
.actions { align-items: stretch; }
.actions-right { width: 100%; justify-content: space-between; align-items: center; }
.actions .btn { flex: 0 1 auto; }
.rights-main { grid-template-columns: 24px minmax(0, 1fr); }
.rights-why-toggle { grid-column: 2; justify-self: start; padding-left: 0; white-space: normal; text-align: left; }
.preview-frame { height: min(68svh, 680px); }
.result-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.result-paper { width: min(190px, 62vw); }
.projects-panel { container-type: inline-size; }

@container (max-width: 32rem) {
  .project { align-items: stretch; flex-direction: column; gap: 10px; }
  .project .preview-actions { align-self: flex-start; }
  .project-main { flex-wrap: wrap; }
  .project-main .tag { margin-left: 45px; }
}

@media (min-width: 600px) {
  .auth-brand { min-block-size: 340px; }
  .format-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-layout { grid-template-columns: minmax(220px, .8fr) minmax(0, 1fr); }
}

@media (min-width: 821px) {
  #authView.auth-shell {
    min-height: 720px;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  }
  .auth-brand { min-height: 720px; min-block-size: 0; }
  .auth-brand-title { font-size: clamp(2.65rem, 4.8vw, 4.375rem); }
  .tabs { display: flex; gap: 26px; }
  .tabs button { width: auto; }
  .auth-form-area { padding: 64px clamp(40px, 5vw, 68px); }
  .mode-grid,
  .details-grid,
  .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-grid .full { grid-column: 1 / -1; }
}

@media (min-width: 1081px) {
  #appView { grid-template-columns: 210px minmax(0, 1fr); }
  .shell-nav {
    top: 94px;
    min-height: calc(100dvh - 122px);
    display: flex;
    padding: 20px 14px;
  }
  .shell-brand { padding: 5px 8px 25px; }
  .shell-brand span,
  .shell-nav-section,
  .shell-nav-spacer,
  .shell-user small,
  .shell-user strong { display: block; }
  .shell-nav nav { display: block; overflow: visible; }
  .shell-nav a { padding: 10px; }
  .shell-user { border-top: 1px solid var(--t-border); margin-top: 20px; padding: 16px 8px 2px; }
  .shell-user button { width: 100%; margin: 0; }
  .mode-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-wrap { grid-template-columns: minmax(0, 1fr) 290px; }
}

@media (hover: hover) and (pointer: fine) {
  .upload-box:hover { border-color: #a9a8a1; background: #fffdf9; }
}

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