/* MONTH iz-specific layout. Shared roles and surfaces live in design-system/. */
:root {
  --sidebar: 328px;
}
[hidden] {
  display: none !important;
}
button {
  border: 1px solid var(--border);
  padding: 8px 14px;
  background: transparent;
}
button:hover {
  background: var(--primary-container);
}
button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
button:disabled {
  cursor: wait;
}
.sheet-close svg {
  width: 18px;
  height: 18px;
}
.app-shell {
  height: 100dvh;
  min-height: 500px;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 112px minmax(0, 1fr);
  padding: 0 32px 24px;
  gap: 0 32px;
  overflow: hidden;
}
.app-header {
  grid-column: 1/-1;
  display: flex;
  position: relative;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--on-surface);
}
.brand {
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand h1 {
  font-size: clamp(27px, 3.8vw, 58px);
  line-height: 0.88;
  margin-top: 26px;
  white-space: nowrap;
}
.brand-description {
  position: absolute;
  top: 14px;
  left: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.header-actions {
  margin-left: auto;
}
.export-button {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 23px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: var(--on-primary);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 2px;
}
.export-button:hover {
  background: var(--action-hover);
}
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
select {
  margin-top: 6px;
}
.row {
  display: flex;
  gap: 12px;
}
.row > label {
  flex: 1;
  min-width: 0;
}
.field {
  display: block;
  margin-top: 16px;
}
.control-section h2 {
  justify-content: space-between;
}
.hint {
  font-size: 12px;
  line-height: 1.8;
  margin-top: 12px;
}
.templates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.template {
  padding: 7px 4px;
  font-size: 11px;
  border-radius: 0;
  background: var(--surface);
}
.template svg {
  display: block;
  width: 100%;
  height: 76px;
  stroke: none;
  margin-bottom: 7px;
}
.template.selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
#fontSample {
  margin-top: 10px;
}
#fontSample svg {
  width: 100%;
  height: 36px;
  display: block;
}
.palettes {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 16px;
}
.palette {
  width: 29px;
  height: 29px;
  border: 3px solid var(--surface-field);
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 0 0 1px var(--border);
}
.palette.active {
  box-shadow: 0 0 0 2px var(--primary);
}
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}
.color-input {
  width: 132px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toggle input {
  accent-color: var(--primary);
  width: 17px;
  height: 17px;
  margin: 0;
}
.error:empty {
  display: none;
}
.error {
  font-size: 12px;
}
/* Keep the settings action inside the canvas boundary. */
.canvas-frame {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border-bottom: 1px solid var(--on-surface);
}
.settings-preview {
  display: none;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 44px;
  padding: 26px 0 0;
  gap: 20px;
  position: relative;
}
.mobile-settings {
  display: none;
}
.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;

  padding: 20px 24px 24px;
  background-image: radial-gradient(#c7c7c2 0.7px, transparent 0.7px);
  background-size: 24px 24px;
}
#poster {
  width: min(100cqw, calc(100cqh * 210 / 297));
  aspect-ratio: 210/297;
  flex-shrink: 0;
  outline: 1px solid var(--border);
  box-shadow: 0 5px 16px #0000000a;
}
#poster svg {
  display: block;
  width: 100%;
  height: 100%;
}
.status-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-top: 10px;
  font-size: 10px;
  color: var(--muted);
}
#sizeLabel {
  justify-self: end;
  text-align: right;
}
.status-bar button {
  border: 0;
  padding: 4px 0;
  min-height: 32px;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.toast {
  position: absolute;
  bottom: 62px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--primary);
  color: var(--on-primary);
  max-width: 90%;
}
.toast:empty {
  display: none;
}
.export-dialog {
  --dialog-width: 850px;
}
.export-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 285px;
  gap: 12px;
}
.export-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  height: 50dvh;
  background: var(--primary-container);
}
.export-preview svg {
  display: block;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  width: auto;
  box-shadow: 0 5px 16px #0000000a;
}
.export-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  font-size: 12px;
  margin-top: 20px;
  padding: 16px 0;
  border-block: 1px solid var(--border-card);
}
.export-details span {
  color: var(--muted);
}
.export-details strong {
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.export-result {
  font-size: 12px;
  line-height: 1.7;
  margin-bottom: 8px;
}
.export-result:empty {
  display: none;
}
.segmented button {
  min-height: 40px;
}
.about-dialog p + p {
  margin-top: 16px;
}
.about-dialog p {
  font-size: 13px;
  line-height: 1.8;
}
.about-dialog details {
  margin-top: 20px;
}
.about-dialog summary {
  cursor: pointer;
}
.about-dialog pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  max-height: 250px;
  overflow: auto;
}
.mobile-save-guide {
  display: none;
  margin-top: 16px;
  border-block: 1px solid var(--border-card);
  font-size: 12px;
  line-height: 1.8;
}
.mobile-save-guide summary {
  min-height: 44px;
  padding: 12px 0;
  cursor: pointer;
  font-weight: 700;
}
.mobile-save-guide-content {
  padding-bottom: 16px;
}
.mobile-save-guide h3 {
  font-size: 12px;
  margin: 12px 0 8px;
}
.sheet-scroll {
  scrollbar-width: thin;
}
.sheet-primary {
  padding: 12px;
}
.settings-dialog .control-section {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 18px;
  margin-bottom: 12px;
}
.settings-dialog .control-section:last-child {
  margin: 0;
}
.settings-dialog #settingsContent {
  overflow: visible;
}
.settings-dialog .color-input {
  border-radius: var(--radius-field);
  background: var(--surface-field);
  min-height: 44px;
}
.settings-dialog .hex-input {
  font-size: 16px;
}
.settings-dialog .toggle {
  min-height: 44px;
}
.settings-dialog .palette {
  width: 34px;
  height: 34px;
}
@media (min-width: 768px) and (max-width: 1199px) {
  :root {
    --sidebar: 280px;
  }
  .app-shell {
    padding: 0 24px 20px;
    gap: 0 24px;
    grid-template-rows: 104px minmax(0, 1fr);
  }
  .workspace {
    padding-top: 22px;
  }
  .brand h1 {
    font-size: 3.7vw;
  }
  .stage {
    padding: 12px 16px;
  }
}
@media (min-width: 768px) and (max-height: 750px) {
  .app-shell {
    grid-template-rows: 96px minmax(0, 1fr);
  }
  .brand h1 {
    font-size: 38px;
    margin-top: 17px;
  }
}
@media (max-width: 767px) {
  .app-shell {
    min-height: 420px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(88px, 18vw, 104px) minmax(0, 1fr);
    padding: 0 14px 12px;
    gap: 0;
  }
  .app-header {
    gap: 12px;
  }
  .brand h1 {
    font-size: clamp(30px, 9.6vw, 64px);
    margin-top: 0;
  }
  .brand-description {
    top: 12px;
    font-size: 9px;
  }
  .export-button {
    width: 84px;
    height: 44px;
    padding: 0 10px;
    gap: 6px;
    margin: 0;
  }
  .export-button svg {
    width: 14px;
    height: 14px;
  }
  .workspace {
    /* Cap unused vertical space when the portrait calendar is width-limited.
       48px: shell + canvas side padding; 185px: controls and vertical spacing. */
    max-height: calc((100vw - 48px) * 297 / 210 + 185px);
    padding: 16px 0 8px;
    grid-template-rows: minmax(0, 1fr) 44px;
    gap: 16px;
  }
  .mobile-settings {
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 96px;
    height: 44px;
    flex-shrink: 0;
    padding: 0 8px;
    border: 1px solid var(--on-surface);
    border-radius: var(--radius-pill);
    font-size: 11px;
  }
  .mobile-settings svg {
    width: 18px;
    height: 18px;
  }
  .stage {
    padding: 18px 10px 8px;
    align-items: flex-end;
  }
  .status-bar {
    gap: 8px;
    font-size: 9px;
  }
  .status-bar button {
    font-size: 9px;
  }
  #caption {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .export-content {
    grid-template-columns: minmax(0, 1fr);
  }
  .export-preview {
    min-height: 0;
    height: 27dvh;
    padding: 16px;
  }
  .mobile-save-guide {
    display: block;
  }
  .sheet-dialog .sheet-scroll {
    flex: 1;
  }
  .sheet-dialog select {
    font-size: 16px;
    min-height: 44px;
  }
  .sheet-dialog .hex-input {
    height: 32px;
  }
  .sheet-dialog .color-picker {
    width: 28px;
    height: 28px;
  }
  .sheet-dialog .template svg {
    height: 88px;
  }
}
@media print {
  body,
  .app-shell {
    background: white;
  }
  .app-shell {
    display: block;
    padding: 0;
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .app-header,
  .settings-panel,
  .mobile-settings,
  .status-bar,
  .toast,
  dialog {
    display: none !important;
  }
  .workspace {
    display: block;
    padding: 0;
  }
  .stage {
    display: block;
    padding: 0;
    background: none;
    container-type: normal;
    border: 0;
  }
  #poster {
    width: 100%;
    height: auto;
    outline: none;
    box-shadow: none;
    aspect-ratio: auto;
  }
  #poster svg {
    width: 100%;
    height: auto;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@media (max-width: 767px) {
  .canvas-frame {
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .canvas-frame .mobile-settings {
    margin: 6px 0 24px;
  }
  .settings-dialog[open] {
    height: 96dvh;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)));
  }
  .settings-dialog .settings-preview {
    display: flex;
    flex: 0 0 clamp(90px, 21dvh, 185px);
    height: clamp(90px, 21dvh, 185px);
    min-height: 0;
    margin: 0 12px 12px;
    padding: 16px;
  }
  #settingsPreview {
    height: 100%;
    aspect-ratio: 210 / 297;
  }
  #settingsPreview svg {
    height: 100%;
    width: 100%;
  }
  .settings-dialog .sheet-heading {
    min-height: 64px;
    padding: 10px 20px;
    flex-shrink: 0;
  }
  .settings-dialog .sheet-eyebrow {
    display: none;
  }
  .settings-dialog .sheet-heading h2 {
    font-size: 22px;
  }
  .settings-dialog #settingsSlot {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
@media print {
  .canvas-frame {
    display: block;
    border: 0;
  }
}
