:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #15171a;
  --muted: #667085;
  --line: #d7dce3;
  --accent: #0b6bcb;
  --accent-dark: #094f96;
  --ok: #147a46;
  --warn: #b54708;
  font-family: Pretendard, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.shell {
  width: min(1480px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 10px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
}

.brand-button img {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.brand-button:hover {
  color: var(--accent);
}

h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.tab,
.subtab,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  padding: 0 10px;
}

.tab.active,
.subtab.active,
button[type="submit"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

button.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.button-link {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

.panel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.panel.active {
  display: block;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
}

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

.job-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.slot-reset,
.slot-regenerate {
  position: absolute;
  z-index: 7;
  top: 8px;
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  border-color: rgba(17, 24, 39, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #475467;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.12);
}

.slot-reset {
  right: 8px;
  font-size: 18px;
}

.slot-regenerate {
  right: 42px;
  font-size: 16px;
}

.slot-reset:hover {
  border-color: rgba(180, 35, 24, 0.28);
  color: #b42318;
}

.slot-regenerate:hover {
  border-color: rgba(11, 107, 203, 0.28);
  color: #0b6bcb;
}

.tool {
  display: grid;
  gap: 6px;
  align-content: start;
}

.t2i-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 12px;
  align-items: stretch;
}

.t2i-tool textarea {
  min-height: 108px;
}

.t2i-preview {
  min-height: 230px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

#i2v form.tool textarea {
  min-height: 108px;
}

#i2i form.tool textarea {
  min-height: 156px;
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: #b42318;
}

.job-card .message {
  position: absolute;
  z-index: 5;
  left: 18px;
  right: 52px;
  top: 18px;
  width: auto;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 0;
  max-height: 68px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid rgba(11, 107, 203, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16);
  color: var(--accent);
  font-size: 13px;
  line-height: 1.35;
}

.job-card .message:not(:empty) {
  display: flex;
}

.job-card .message.error {
  border-color: rgba(180, 35, 24, 0.26);
  background: rgba(255, 248, 246, 0.96);
  color: #b42318;
}

.message > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-close {
  flex: 0 0 auto;
  margin-left: auto;
  width: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.preview,
.prompt-box {
  min-height: 360px;
  border: 1px dashed #b7c0cc;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fbfcfe;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview span {
  color: var(--muted);
}

.preview.compact {
  height: clamp(250px, 44vh, 410px);
  min-height: 0;
}

.upload-zone {
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: #f6f9ff;
  box-shadow: inset 0 0 0 1px rgba(25, 112, 211, 0.14);
}

.upload-zone .image-viewer,
.upload-zone .video-viewer,
.upload-zone .upload-preview,
.upload-zone video,
.upload-zone img {
  cursor: default;
}

.upload-zone .viewer-image,
.upload-zone .library-media-button {
  cursor: zoom-in;
}

form.tool input[type="file"][name="image"] {
  display: none;
}

.control-row {
  display: grid;
  grid-template-columns: 80px 92px minmax(0, 1fr);
  gap: 8px;
}

.control-row select,
.control-row input[type="number"],
.control-row button {
  min-height: 42px;
}

.upload-preview {
  position: relative;
  width: 100%;
  height: 100%;
}

.upload-preview img {
  display: block;
}

.upload-preview span {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.video-chain {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 8px;
}

.image-chain {
  width: 100%;
  height: 100%;
  padding: 8px;
}

.image-viewer,
.video-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f4f6f8;
}

.viewer-image {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.viewer-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-viewer > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111827;
}

.viewer-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 30px;
  min-width: 30px;
  min-height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.12);
  color: #111827;
  font-size: 24px;
  line-height: 1;
  opacity: 0.72;
  transform: translateY(-50%);
}

.image-viewer:hover .viewer-nav,
.video-viewer:hover .viewer-nav,
.viewer-nav:focus-visible {
  opacity: 1;
}

.viewer-nav.prev {
  left: 6px;
}

.viewer-nav.next {
  right: 6px;
}

.viewer-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.viewer-meta {
  position: absolute;
  z-index: 3;
  left: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.viewer-meta {
  top: 6px;
}

.viewer-meta-image {
  justify-content: flex-start;
}

.viewer-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.62);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  backdrop-filter: blur(6px);
}

.chain-track {
  display: grid;
  grid-auto-columns: minmax(190px, 88%);
  grid-auto-flow: column;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline mandatory;
}

.chain-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  scroll-snap-align: start;
}

.chain-card video {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: cover;
  background: #eef1f5;
}

.image-card img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #eef1f5;
}

.chain-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 7px 0;
  font-size: 12px;
}

.chain-meta span,
.chain-card p {
  color: var(--muted);
}

.chain-card p {
  display: -webkit-box;
  min-height: 34px;
  margin: 4px 7px 8px;
  overflow: hidden;
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-box {
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 12px;
  gap: 12px;
}

.prompt-box textarea {
  height: 100%;
  min-height: 260px;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-row button,
#refreshLibrary {
  padding: 0 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-actions button {
  min-height: 36px;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.subtab {
  min-width: 112px;
  min-height: 38px;
  padding: 0 14px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  overflow: hidden;
}

.media-wrap {
  position: relative;
  background: #eef1f5;
}

.library-media-button {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.12) 75%);
  background-color: #f8fafc;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  cursor: zoom-in;
}

.media-wrap > span {
  display: grid;
  aspect-ratio: 16 / 9;
  place-items: center;
  color: var(--muted);
}

.item-select {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.item-select input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.item img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #eef1f5;
}

.item video {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #05070a;
}

.item img,
.item video {
  display: block;
  border-radius: 0;
}

.library-media-button img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: contain;
}

.item-body {
  display: grid;
  gap: 8px;
  padding: 10px 10px 12px;
}

.item-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.item-title-row strong {
  font-size: 14px;
}

.item-title-row span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
}

.item code,
pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.item p {
  color: var(--muted);
  font-size: 13px;
}

.prompt-line {
  display: -webkit-box;
  min-height: 38px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-details,
.extend-panel {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.item-details summary,
.extend-panel summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.item-details dl {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
}

.item-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.item-details dd {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-library {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfe;
}

.extend-form {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.inline-extend {
  margin-top: 0;
}

.extend-form textarea {
  min-height: 58px;
  padding: 8px 9px;
  font-size: 14px;
}

.inline-extend textarea {
  min-height: 46px;
  font-size: 13px;
}

.extend-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
}

.extend-row button,
.extend-row select {
  min-height: 38px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

pre,
.error-list {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  margin: 0;
}

.error-list p {
  margin-bottom: 10px;
  color: var(--warn);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.oauth-config {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.proxy-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 14px 0;
  background: #fbfcfe;
}

.proxy-box textarea {
  min-height: 72px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.device-login {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
  background: #fff;
  display: none;
}

.device-login.active {
  display: block;
}

.device-login code {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 6px;
  background: #eef1f5;
  font-weight: 800;
}

.oauth-result {
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 18px;
  background: rgba(0, 0, 0, 0.64);
  overflow: hidden;
}

.lightbox.active {
  display: flex;
}

.lightbox-media {
  position: absolute;
  z-index: 1;
  inset: 36px 18px 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
}

.lightbox-media img,
.lightbox-media video {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 54px);
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.lightbox-close {
  position: fixed;
  z-index: 2;
  top: 18px;
  right: 18px;
  width: 44px;
  min-width: 44px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.92);
  font-size: 28px;
}

.t2i-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.t2i-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 8px;
  overflow: auto;
}

.t2i-result {
  min-height: 0;
  padding: 0;
  border: 0;
  background: #f8fafc;
  cursor: zoom-in;
}

.t2i-result img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: contain;
}

.library-head {
  align-items: center;
}

.compact-icon {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 16px;
}

.danger-icon {
  color: #b42318;
}

.notes-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 12px;
}

.note-window {
  position: fixed;
  z-index: 30;
  top: 96px;
  left: 50%;
  width: min(920px, calc(100vw - 28px));
  max-height: min(78vh, 720px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  transform: translateX(-50%);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.note-window.is-dragging {
  user-select: none;
}

.note-window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: #1d2939;
  cursor: move;
  font-size: 13px;
  font-weight: 700;
}

.note-window-close {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #667085;
  font-size: 20px;
}

.note-window-close:hover {
  background: #eef2f6;
  color: #101828;
}

.note-window .notes-layout {
  max-height: calc(min(78vh, 720px) - 42px);
  padding: 12px;
  overflow: auto;
}

.note-editor,
.note-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.note-editor {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
}

.note-editor textarea {
  min-height: 220px;
}

.note-actions,
.note-card-actions {
  display: flex;
  gap: 8px;
}

.note-actions button,
.note-card-actions button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.note-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 170px;
  padding: 12px;
}

.note-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.note-card-head strong {
  line-height: 1.35;
}

.note-card-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.note-card p {
  display: -webkit-box;
  min-height: 64px;
  margin: 0;
  overflow: hidden;
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  white-space: pre-wrap;
}

.danger-text {
  color: #b42318;
}

[hidden] {
  display: none !important;
}

.item-select {
  min-width: 34px;
  justify-content: center;
}

.item-select span {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.item.trashed {
  opacity: 0.88;
}

.item-body {
  gap: 7px;
  padding: 9px 10px 10px;
}

.item-title-row {
  align-items: center;
}

.item-title-row strong {
  font-size: 13px;
}

.item-title-row span {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef1f5;
  font-size: 11px;
  font-weight: 800;
}

.prompt-line {
  min-height: 0;
  margin: 0;
  color: #344054;
  line-height: 1.35;
}

.item-toolbar {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.library-icon-action {
  width: 36px;
  min-height: 34px;
  padding: 0;
  border-radius: 7px;
  font-size: 17px;
  line-height: 1;
}

.library-icon-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.compact-extend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 42px;
  gap: 6px;
  align-items: center;
  margin-top: 0;
  grid-column: 1 / -1;
}

.compact-extend input,
.compact-extend select,
.compact-extend button {
  min-height: 36px;
  border-radius: 7px;
}

.compact-extend input {
  padding: 7px 8px;
}

.compact-extend button {
  padding: 0;
}

.compact-extend .message {
  grid-column: 1 / -1;
  min-height: 0;
  font-size: 12px;
}

.item-details {
  border-top: 0;
  padding-top: 0;
  grid-column: 1 / -1;
}

.item-details.has-side-action {
  grid-column: 2;
}

.item-details summary {
  font-size: 12px;
}

.item-details dl {
  grid-template-columns: 70px minmax(0, 1fr);
}

@media (max-width: 780px) {
  .shell {
    width: min(100vw - 16px, 540px);
    padding: 10px 0 24px;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .topbar p {
    display: none;
  }

  h1 {
    font-size: 21px;
  }

  .grid.two,
  .t2i-workspace,
  .settings-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .note-window {
    top: 72px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 88px);
  }

  .note-window .notes-layout {
    grid-template-columns: 1fr;
    max-height: calc(100vh - 130px);
  }

  .tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    min-width: 82px;
    min-height: 36px;
    padding: 0 8px;
    font-size: 13px;
    white-space: nowrap;
  }

  #i2i .job-grid,
  #i2v .job-grid,
  #t2i .job-grid {
    display: grid;
    grid-auto-columns: minmax(82vw, 360px);
    grid-auto-flow: column;
    grid-template-columns: none;
    gap: 10px;
    margin: 0 -8px;
    padding: 0 8px 8px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
  }

  #i2i .job-card,
  #i2v .job-card,
  #t2i .job-card {
    scroll-snap-align: start;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .library-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .library-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
  }

  .subtabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }

  .subtab {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .compact-icon {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
  }

  .library-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .notes-list {
    grid-template-columns: 1fr;
  }

  .note-editor textarea {
    min-height: 150px;
  }

  .preview,
  .prompt-box {
    min-height: 210px;
  }

  .preview.compact {
    height: min(52vh, 360px);
    min-height: 190px;
  }

  textarea {
    min-height: 96px;
  }

  #i2v form.tool textarea {
    min-height: 108px;
  }

  #i2i form.tool textarea {
    min-height: 156px;
  }

  .t2i-controls {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .control-row {
    grid-template-columns: 76px 84px minmax(0, 1fr);
  }

  .compact-extend {
    grid-template-columns: minmax(0, 1fr) 82px 38px;
  }

  input[type="file"] {
    font-size: 14px;
  }
}

@media (min-width: 781px) and (max-width: 1180px) {
  .job-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
