/* Shared App Primitives */
.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--surface-sidebar);
  border-right: 1px solid var(--divider);
  padding: 10px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 8px 10px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  min-height: 34px;
}

.sidebar-item:hover {
  background: var(--glass-bg-subtle);
}

.sidebar-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-input {
  background: var(--surface-input);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.app-input:focus {
  border-color: var(--accent);
}

.app-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

@media (max-width: 640px) {
  .app-shell.responsive-collapse {
    flex-direction: column;
  }
  .app-shell.responsive-collapse .app-sidebar {
    width: 100%;
    max-height: 112px;
    border-right: none;
    border-bottom: 1px solid var(--divider);
    flex-direction: row;
    flex-wrap: wrap;
  }
  .app-shell.responsive-collapse .sidebar-section-label {
    display: none;
  }
  .app-shell.responsive-collapse .sidebar-item {
    width: auto;
    padding: 5px 10px;
  }
}

/* Finder */
.finder-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  flex: 1;
  min-width: 120px;
  overflow-x: auto;
}

.crumb-btn {
  border: none;
  background: transparent;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.crumb-btn:hover {
  background: var(--glass-bg-subtle);
}

.finder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 12px;
}

.finder-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
}

.finder-item:hover {
  background: var(--surface-card);
}

.finder-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.finder-item-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.finder-item-icon svg {
  width: 46px;
  height: 46px;
}

.finder-item-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.finder-item-name {
  font-size: 12px;
  word-break: break-word;
  line-height: 1.25;
}

.finder-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.finder-list-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px 90px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
}

.finder-list-row:hover {
  background: var(--surface-card);
}

.finder-list-row.selected {
  background: var(--accent-soft);
}

.finder-statusbar {
  padding: 6px 12px;
  border-top: 1px solid var(--divider);
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* Navigator Browser */
.browser-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 0;
  background: var(--surface-sidebar);
  border-bottom: 1px solid var(--divider);
  overflow-x: auto;
}

.browser-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  max-width: 170px;
  white-space: nowrap;
}

.browser-tab.active {
  background: var(--surface-app);
  font-weight: 600;
}

.browser-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.browser-tab-close {
  opacity: 0.6;
  font-size: 12px;
  padding: 0 2px;
}

.browser-bookmarks-bar {
  display: flex;
  gap: 6px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--divider);
  overflow-x: auto;
  font-size: 12px;
}

.bookmark-pill {
  border: none;
  background: var(--surface-card);
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 11.5px;
}

.bookmark-pill:hover {
  background: var(--accent-soft);
}

.browser-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--surface-app);
  overflow: hidden;
}

.browser-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.browser-home {
  height: 100%;
  overflow-y: auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.browser-favorites-grid {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.browser-fav-card {
  background: var(--surface-card);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
}

.browser-fav-card:hover {
  border-color: var(--accent);
}

/* Notes & TextEdit */
.notes-list-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notes-list-item:hover {
  background: var(--glass-bg-subtle);
}

.notes-list-item.active {
  background: var(--accent-soft);
}

.notes-editor-title {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 20px;
  font-weight: 700;
  outline: none;
  padding: 12px 16px 6px;
}

.notes-editor-body,
.textedit-textarea {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  padding: 8px 16px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.textedit-textarea.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Calendar */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 0;
}

.cal-day {
  min-height: 54px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-card);
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  font-size: 12px;
}

.cal-day.other-month {
  opacity: 0.36;
}

.cal-day.today {
  border-color: var(--accent);
}

.cal-day.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.cal-dots {
  display: flex;
  gap: 3px;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

/* Calculator */
.calc-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px;
  gap: 10px;
}

.calc-display {
  background: var(--surface-input);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 12px 14px;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-expr {
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-value {
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calc-grid {
  flex: 1;
  display: grid;
  gap: 7px;
}

.calc-grid.standard {
  grid-template-columns: repeat(4, 1fr);
}

.calc-grid.scientific {
  grid-template-columns: repeat(5, 1fr);
}

.calc-key {
  border: none;
  border-radius: 11px;
  background: var(--surface-card);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: transform 0.08s ease, background 0.12s ease;
}

.calc-key:hover {
  background: var(--glass-bg-subtle);
}

.calc-key:active {
  transform: scale(0.95);
}

.calc-key.op {
  background: var(--accent);
  color: #fff;
}

.calc-key.fn {
  background: rgba(128, 138, 158, 0.22);
  font-size: 13px;
}

.calc-key.span-2 {
  grid-column: span 2;
}

/* Photos & Preview */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.photo-tile {
  aspect-ratio: 4/3;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface-card);
  padding: 0;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-tile:hover {
  border-color: var(--accent);
}

.photo-editor-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  padding: 14px;
}

.photo-editor-stage canvas,
.photo-editor-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}

/* Terminal */
.terminal-root {
  flex: 1;
  min-height: 0;
  background: rgba(11, 15, 23, 0.96);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  cursor: text;
}

.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.term-prompt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.term-prompt-label {
  color: #38bdf8;
  font-weight: 700;
  white-space: nowrap;
}

.term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f8fafc;
  font-family: inherit;
  font-size: inherit;
}

/* Settings & Activity Monitor & App Store */
.settings-group {
  background: var(--surface-card);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.accent-swatch {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
}

.accent-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

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

.wallpaper-card {
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface-card);
  padding: 0;
  text-align: left;
}

.wallpaper-card.active {
  border-color: var(--accent);
}

.wallpaper-card-preview {
  height: 74px;
  background-size: cover;
  background-position: center;
}

.wallpaper-card-name {
  padding: 6px 8px;
  font-size: 11.5px;
  font-weight: 600;
}

.monitor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.monitor-table th,
.monitor-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--divider);
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.store-card {
  background: var(--surface-card);
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.store-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.store-card-head svg {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
