/* Reset, forms, buttons, auth, dialogs */

:root {
  --node-width: 320px;
  --workspace-inset: 6px;
  --workspace-top: 60px;
  --workspace-radius: 16px;
  --workspace-gap: 6px;
  --chat-column-width: clamp(280px, 32vw, 480px);
  --dock-overlay-z: 45;
  --dock-panel-z: 50;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.brand-overlay {
  position: fixed;
  top: 18px;
  left: 22px;
  z-index: 20;
  height: clamp(28px, 4vw, 100px);
  width: auto;
  pointer-events: none;
  user-select: none;
}

.workspace-brand-bar {
  position: fixed;
  top: 30px;
  left: 32px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0;
  transform: translateY(-50%);
  pointer-events: none;
}

.workspace-brand {
  height: 20px;
  width: auto;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.user-avatar {
  position: fixed;
  top: 30px;
  right: 16px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: var(--dock);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  transform: translateY(-50%);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.user-avatar:hover,
.user-avatar.is-open {
  color: var(--accent-strong);
  background: var(--accent-surface-strong);
  border-color: var(--accent-border);
}

.user-avatar:focus-visible {
  outline: 1px solid var(--accent-strong);
  outline-offset: 2px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.loading-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.loading-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  animation: loading-fade-in 0.7s ease;
}

.loading-logo {
  height: clamp(52px, 9vw, 80px);
  width: auto;
  opacity: 0.9;
}

.loading-indicator {
  display: flex;
  gap: 7px;
  align-items: center;
  height: 10px;
}

.loading-indicator span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  opacity: 0.28;
  animation: loading-dot 1.15s ease-in-out infinite;
}

.loading-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.loading-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

.loading-status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

@keyframes loading-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loading-dot {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: scale(0.82);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: min(480px, 100%);
  padding: 32px;
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.08em;
}

.auth-form,
.workspace-create {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.workspace-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.workspace-create-row .primary-button {
  min-height: 44px;
  height: 44px;
  padding: 0 18px;
}

.error-message {
  margin: 0;
  border: 1px solid var(--error-border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--error-text);
  background: var(--error-surface);
  font-weight: 700;
}

.workspace-list-section {
  display: grid;
  gap: 12px;
}

.workspace-list-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.workspace-card-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.workspace-shared-icon {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.workspace-card strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-card-actions,
.dialog-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workspace-manager {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: var(--dock-panel-z);
  display: grid;
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  transform: translate(-50%, -50%);
  gap: 18px;
  overflow: auto;
  padding: 20px;
  background: var(--dock-panel-bg);
  border: 1px solid var(--dock-panel-border);
  border-radius: 16px;
}

.workspace-list {
  display: grid;
  gap: 20px;
}

.workspace-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--surface-strong);
  border-radius: 18px;
  padding: 14px;
  background: var(--surface-subtle);
}

.workspace-card.is-active {
  border-color: var(--accent-border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.danger-button {
  color: var(--error-text);
  background: var(--error-surface-strong);
}

.logout-button {
  flex-shrink: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--overlay-strong);
  backdrop-filter: blur(8px);
}

.edit-dialog,
.delete-dialog {
  display: grid;
  width: min(520px, 100%);
  gap: 16px;
  padding: 24px;
}

.edit-dialog h2,
.delete-dialog h2,
.delete-dialog p {
  margin: 0;
}

.delete-dialog p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.5;
}

.credits-exhausted-dialog {
  width: min(480px, 100%);
}

.credits-exhausted-dialog .dialog-actions {
  justify-content: flex-end;
}

.content-rights-dialog-actions {
  justify-content: flex-end;
  margin-top: 4px;
}

.content-rights-dialog-actions .ghost-button,
.content-rights-dialog-actions .primary-button {
  min-height: 36px;
  height: 36px;
  padding: 0 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px 22px;
}

.topbar h1,
.card h2,
.canvas-toolbar h2 {
  margin: 0;
}

.topbar h1 {
  max-width: 840px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.07em;
}

.hero-copy {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.section-heading,
.toggle-row,
.settings-grid,
.url-row {
  display: grid;
  gap: 14px;
}

.section-heading {
  grid-template-columns: 1fr auto;
  align-items: center;
}

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

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.url-row {
  grid-template-columns: 1fr 0.72fr;
  align-items: end;
}

.toggle-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--input-text, var(--text));
  background: var(--panel-soft);
  outline: none;
}

input,
select {
  height: 44px;
  padding: 0 14px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='none' stroke='%238b93a5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 L6 8 L9.5 4.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

select::-ms-expand {
  display: none;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 14px;
}

.prompt-node textarea {
  resize: both;
  min-width: 292px;
  max-width: 960px;
}

.prompt-textarea-shell {
  position: relative;
  display: grid;
  width: fit-content;
  max-width: 100%;
}

.prompt-textarea-highlight,
.prompt-textarea-shell .prompt-textarea-input {
  grid-area: 1 / 1;
  min-height: 160px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--node-border);
  border-radius: 12px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.prompt-textarea-highlight {
  overflow: hidden;
  resize: none;
  pointer-events: none;
  color: var(--prompt-text, var(--text));
  background: var(--node-input-bg);
  box-shadow: inset 0 1px 0 rgb(0 0 0 / 38%);
  scrollbar-width: none;
}

.prompt-textarea-highlight::-webkit-scrollbar {
  display: none;
}

.prompt-textarea-shell .prompt-textarea-input {
  overflow: auto;
  resize: both;
  min-width: 292px;
  max-width: 960px;
  color: transparent;
  background: transparent;
  caret-color: var(--prompt-text, var(--text));
}

.prompt-textarea-shell .prompt-textarea-input::placeholder {
  color: var(--prompt-placeholder, var(--muted));
  opacity: 1;
}

.prompt-textarea-shell:focus-within .prompt-textarea-highlight,
.prompt-textarea-shell:focus-within .prompt-textarea-input {
  border-color: var(--node-input-focus);
  box-shadow: 0 0 0 1px var(--node-input-focus);
}

.prompt-textarea-highlight .prompt-mention-valid {
  color: var(--accent-strong);
  font-weight: 500;
}

.prompt-textarea-highlight .prompt-mention-obsolete {
  color: #ef4444;
  font-weight: 500;
}

.prompt-textarea-shell .prompt-textarea-input:focus {
  border-color: var(--node-input-focus);
  box-shadow: 0 0 0 1px var(--node-input-focus);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-surface);
}

.checkbox-line {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
}

.file-drop {
  display: flex;
  min-height: 104px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--surface-faint);
  text-align: center;
}

.file-drop input {
  display: none;
}

.file-drop span {
  color: var(--text);
  font-size: 1rem;
}

.file-drop small {
  color: var(--muted);
  font-weight: 500;
}

.file-upload-label {
  min-height: 44px;
  cursor: pointer;
  place-items: center;
  border: 1px dashed var(--surface-hover-border);
  border-radius: 14px;
  color: var(--text);
  background: rgb(255 255 255 / 6%);
  text-align: center;
}

.file-upload-label:hover {
  border-color: var(--accent);
}

.file-upload-label input {
  display: none;
}

.reference-url-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: end;
}

.reference-upload-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.reference-upload-button .material-symbols-outlined {
  font-size: 22px;
  line-height: 1;
}

.reference-upload-button.is-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.reference-url-label {
  min-width: 0;
}

.reference-hidden-file-input {
  display: none;
}

.upload-status {
  margin: 0;
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 700;
}

.upload-status.is-error {
  color: #ffc0c7;
}

.reference-upload-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgb(213 221 231 / 88%);
}

.reference-upload-status.is-busy {
  color: rgb(189 198 212 / 92%);
}

.reference-upload-status.is-ready {
  color: var(--success);
}

.reference-upload-status.is-error {
  color: #ffc0c7;
}

.reference-upload-status-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.reference-upload-status.is-busy .reference-upload-status-icon {
  animation: media-preview-spin 0.9s linear infinite;
}

.reference-flow-node.is-uploading .image-preview,
.reference-flow-node.is-uploading .video-preview,
.reference-flow-node.is-uploading .audio-preview {
  border-color: rgb(90 167 255 / 45%);
}

.media-preview-uploading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.media-upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgb(15 18 24 / 62%);
  pointer-events: none;
}

.drive-link {
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 14px;
  font-weight: 800;
}

.primary-button {
  min-height: 52px;
  color: white;
  background: linear-gradient(135deg, var(--accent), #24c6dc);
}

.primary-button.is-stop {
  background: var(--danger, #e5484d);
}

.primary-button.is-stop:not(:disabled):hover {
  filter: brightness(1.08);
}

.secondary-button {
  height: 44px;
  padding: 0 18px;
  color: white;
  background: var(--accent);
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: var(--chip-bg);
}

.ghost-button.workspace-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
}

.ghost-button.panel-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
}

.ghost-button.workspace-action-button .material-symbols-outlined {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.ghost-button.panel-close-button .material-symbols-outlined {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--success);
  background: rgb(56 189 148 / 14%);
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
