/* MindOS Web Clipper popup */

:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #f2efe8;
  --surface-muted: #ece8df;
  --fg: #1d1a17;
  --fg-secondary: #544d44;
  --fg-muted: #787066;
  --fg-hint: #9a9186;
  --border: rgba(29, 26, 23, 0.10);
  --border-soft: rgba(29, 26, 23, 0.06);
  --amber: #c8873a;
  --amber-hover: #b9772d;
  --amber-foreground: #ffffff;
  --amber-subtle: rgba(200, 135, 58, 0.12);
  --amber-soft: rgba(200, 135, 58, 0.08);
  --success: #5f8f67;
  --success-subtle: rgba(95, 143, 103, 0.12);
  --error: #c85050;
  --error-subtle: rgba(200, 80, 80, 0.10);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(29, 26, 23, 0.05);
  --shadow-md: 0 6px 18px rgba(29, 26, 23, 0.08);
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 160ms var(--ease-out);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1d1b18;
    --surface-soft: #25231f;
    --surface-muted: #2b2823;
    --fg: #ede8df;
    --fg-secondary: #d0c8bd;
    --fg-muted: #9f968a;
    --fg-hint: #7b7368;
    --border: rgba(237, 232, 223, 0.10);
    --border-soft: rgba(237, 232, 223, 0.06);
    --amber: #d4954a;
    --amber-hover: #e0a45a;
    --amber-subtle: rgba(212, 149, 74, 0.16);
    --amber-soft: rgba(212, 149, 74, 0.10);
    --success: #7ca57f;
    --success-subtle: rgba(124, 165, 127, 0.14);
    --error: #f07878;
    --error-subtle: rgba(240, 120, 120, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.32);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  width: 372px;
  min-height: 240px;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
}

#app {
  padding: 12px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 180ms var(--ease-out);
}

.view[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.view-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup img {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--fg-muted);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-chip-neutral {
  color: var(--fg-secondary);
  background: var(--surface-soft);
  border-color: var(--border-soft);
}

.status-chip-success {
  color: var(--success);
  background: var(--success-subtle);
  border-color: rgba(95, 143, 103, 0.18);
}

.status-chip-error {
  color: var(--error);
  background: var(--error-subtle);
  border-color: rgba(200, 80, 80, 0.18);
}

.status-chip-loading {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(200, 135, 58, 0.16);
}

.surface {
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.intro-surface,
.clip-surface,
.success-surface,
.loading-surface {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.surface-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.surface-copy h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--fg);
}

.surface-copy p {
  margin: 0;
  color: var(--fg-secondary);
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-secondary);
}

.form-group input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.form-group input::placeholder {
  color: var(--fg-hint);
}

.form-group input:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-subtle);
}

.hint {
  margin: 0;
  font-size: 11px;
  color: var(--fg-hint);
}

.btn-primary,
.btn-secondary,
.btn-icon,
.dir-trigger,
.dir-breadcrumb button,
.dir-item,
.dir-confirm {
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform 100ms var(--ease-out);
}

.btn-primary,
.btn-secondary,
.btn-icon {
  border: 0;
  cursor: pointer;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--amber);
  color: var(--amber-foreground);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--amber-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary:disabled,
.btn-icon:disabled,
.dir-trigger:disabled,
.dir-confirm:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.dir-trigger:focus-visible,
.dir-confirm:focus-visible,
.dir-breadcrumb button:focus-visible,
.dir-item:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.btn-text,
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loading[hidden] {
  display: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--border);
}

.btn-secondary:active {
  transform: translateY(1px);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  color: var(--fg-muted);
  background: transparent;
}

.btn-icon:hover {
  color: var(--fg);
  background: var(--surface-soft);
}

.clip-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  color: var(--fg-muted);
}

.clip-site {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  word-break: break-word;
}

.title-input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-weight: 500;
}

.title-input:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-subtle);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.clip-source {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--fg-secondary);
  border: 1px solid var(--border-soft);
}

.meta-badge svg {
  flex: 0 0 auto;
}

.meta-badge-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert {
  display: flex;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius);
  background: var(--error-subtle);
  color: var(--error);
  line-height: 1.45;
}

.alert[hidden] {
  display: none !important;
}

.spinner {
  width: 18px;
  height: 18px;
  animation: spin 0.9s linear infinite;
}

.spinner.large {
  width: 28px;
  height: 28px;
}

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

.dir-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  text-align: left;
}

.dir-trigger:hover {
  border-color: rgba(29, 26, 23, 0.18);
  background: var(--surface-soft);
}

.dir-trigger.active {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-subtle);
}

.dir-trigger:disabled {
  background: var(--surface-soft);
}

.dir-icon {
  flex: 0 0 auto;
  color: var(--amber);
}

.dir-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.dir-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-hint {
  font-size: 11px;
  color: var(--fg-muted);
}

.dir-chevron {
  flex: 0 0 auto;
  color: var(--fg-hint);
  transition: transform var(--transition);
}

.dir-trigger.active .dir-chevron {
  transform: rotate(180deg);
}

.dir-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.dir-panel[hidden] {
  display: none;
}

.dir-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-soft);
  overflow-x: auto;
}

.dir-breadcrumb button {
  flex: 0 0 auto;
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 11px;
}

.dir-breadcrumb button:hover {
  background: var(--amber-soft);
  color: var(--fg);
}

.dir-breadcrumb button.active {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: rgba(200, 135, 58, 0.18);
}

.crumb-sep {
  flex: 0 0 auto;
  color: var(--fg-hint);
  font-size: 10px;
}

.dir-list {
  max-height: 184px;
  overflow-y: auto;
}

.dir-list:empty::after {
  content: 'No subdirectories';
  display: block;
  padding: 14px 12px;
  color: var(--fg-hint);
  font-size: 11px;
  text-align: center;
}

.dir-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}

.dir-item:hover {
  background: var(--amber-soft);
}

.dir-item.active {
  background: rgba(200, 135, 58, 0.14);
}

.dir-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--amber);
}

.dir-item-icon,
.dir-item-arrow {
  flex: 0 0 auto;
}

.dir-item-icon {
  color: var(--amber);
}

.dir-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-item-arrow {
  color: var(--fg-hint);
}

.dir-confirm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 38px;
  border: 0;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--amber);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dir-confirm:hover {
  background: var(--amber-soft);
}

.success-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--success-subtle);
  border: 1px solid rgba(95, 143, 103, 0.16);
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.success-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
}

.success-detail {
  margin: 0;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg-secondary);
  font-size: 11px;
  font-family: var(--font-mono);
  line-height: 1.4;
  word-break: break-all;
  text-align: center;
}

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

.success-actions .btn-primary,
.success-actions .btn-secondary {
  flex: 1;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 34px 0 26px;
}

.loading-brand {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.loading-text {
  margin: 0;
  color: var(--fg-secondary);
  font-size: 13px;
}
