:root {
  --page-bg: #fdfdfd;
  --card-bg: #17191a;
  --card-border: rgba(255, 255, 255, 0.065);
  --divider: rgba(255, 255, 255, 0.07);
  --text-primary: #f2f3f5;
  --text-secondary: #8c8f96;
  --text-muted: #767980;
  --pill-bg: rgba(255, 255, 255, 0.065);
  --btn-bg: #252729;
  --btn-hover: #2f3235;
  --btn-border: rgba(255, 255, 255, 0.09);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page-bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.storage-card {
  width: 620px;
  max-width: 100%;
  background: var(--card-bg);
  border-radius: 17px;
  border: 1px solid var(--card-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 18px 44px -10px rgba(0, 0, 0, 0.16),
    0 4px 14px -3px rgba(0, 0, 0, 0.08);
  overflow: visible;
  user-select: none;
}

/* Header */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 26px 0 26px;
  gap: 16px;
}

.usage-group {
  min-width: 0;
  flex: 1;
}

.usage-headline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.15;
}

.usage-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #f4f5f7;
  font-variant-numeric: tabular-nums;
}

.usage-capacity {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.subtitle-row {
  margin-top: 6px;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.25px;
  line-height: 20px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.subtitle-row .sub-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.subtitle-row .sub-title {
  color: #e9eaed;
  font-weight: 500;
  flex-shrink: 0;
}

.subtitle-row .sub-size {
  color: #8c8f96;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.subtitle-row .sub-detail {
  color: #7c7f86;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle-row .sub-action-label {
  color: #a6a9b0;
  font-weight: 450;
  flex-shrink: 0;
}

.subtitle-row .sub-path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #6d7077;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle-row .sub-freed {
  color: #e6e7ea;
  font-weight: 500;
}

.subtitle-row .sub-avail {
  color: #7a7d84;
  font-variant-numeric: tabular-nums;
}

/* Rescan button */
.rescan-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #a1a4ab;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: -4px -8px 0 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    opacity 180ms ease,
    transform 120ms ease;
}

.rescan-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.065);
  color: #eceef0;
}

.rescan-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.rescan-btn:disabled {
  opacity: 0.48;
  cursor: default;
}

.rescan-icon {
  transition: transform 200ms ease;
}

.rescan-btn.is-spinning .rescan-icon {
  animation: rescanSpin 900ms linear infinite;
}

@keyframes rescanSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

/* Pixel Dot Bar */
.bar-wrapper {
  position: relative;
  margin: 18px 26px 0 26px;
  height: 82px;
}

.dot-canvas {
  position: absolute;
  left: -16px;
  top: -64px;
  width: calc(100% + 32px);
  height: calc(100% + 80px);
  pointer-events: none;
  display: block;
}

.bar-hit-layer {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 11px;
  cursor: default;
  z-index: 2;
}

/* Legend 3x3 Grid */
.legend-grid {
  position: relative;
  margin: 20px 26px 20px 26px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 24px;
  row-gap: 4px;
}

.legend-pill {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 8px;
  background: var(--pill-bg);
  border: 1px solid rgba(255, 255, 255, 0.045);
  pointer-events: none;
  opacity: 0;
  will-change: transform, width, height, opacity;
  z-index: 0;
}

.legend-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  cursor: default;
  transition: opacity 200ms ease;
}

.legend-item.is-dimmed {
  opacity: 0.42;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.legend-name {
  font-size: 12.5px;
  font-weight: 450;
  color: #dfe1e5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 160ms ease;
}

.legend-item.is-active .legend-name {
  color: #ffffff;
}

.legend-size {
  font-size: 12.5px;
  font-weight: 400;
  color: #7c7f86;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  transition: color 160ms ease;
}

.legend-item.is-active .legend-size {
  color: #a4a7ae;
}

/* Divider & Footer */
.card-divider {
  height: 1px;
  background: var(--divider);
  margin: 0;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 26px 14px 26px;
  min-height: 58px;
}

.footer-status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 12.25px;
  line-height: 1.35;
  color: #d6d7db;
}

.footer-status.is-muted {
  color: #797c83;
}

.footer-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.footer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 8-spoke activity spinner */
.mac-spinner {
  width: 14px;
  height: 14px;
  position: relative;
  display: inline-block;
  animation: macSpinnerStep 960ms steps(8, end) infinite;
}

.mac-spinner span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5px;
  height: 3.4px;
  margin-left: -0.75px;
  margin-top: -6.5px;
  border-radius: 1px;
  background: #8a8d94;
  transform-origin: 0.75px 6.5px;
}

.mac-spinner span:nth-child(1) { transform: rotate(0deg); opacity: 1; }
.mac-spinner span:nth-child(2) { transform: rotate(45deg); opacity: 0.85; }
.mac-spinner span:nth-child(3) { transform: rotate(90deg); opacity: 0.7; }
.mac-spinner span:nth-child(4) { transform: rotate(135deg); opacity: 0.55; }
.mac-spinner span:nth-child(5) { transform: rotate(180deg); opacity: 0.42; }
.mac-spinner span:nth-child(6) { transform: rotate(225deg); opacity: 0.3; }
.mac-spinner span:nth-child(7) { transform: rotate(270deg); opacity: 0.22; }
.mac-spinner span:nth-child(8) { transform: rotate(315deg); opacity: 0.14; }

@keyframes macSpinnerStep {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.action-btn {
  appearance: none;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: #f0f1f4;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 9px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    opacity 180ms ease,
    transform 120ms ease;
}

.action-btn:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: rgba(255, 255, 255, 0.14);
}

.action-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.action-btn.is-hidden {
  display: none;
}

@media (max-width: 620px) {
  .stage {
    padding: 14px;
  }

  .card-header {
    padding: 18px 18px 0 18px;
  }

  .bar-wrapper {
    margin: 16px 18px 0 18px;
    height: 68px;
  }

  .legend-grid {
    margin: 16px 18px 18px 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-footer {
    padding: 12px 18px;
    flex-wrap: wrap;
  }

  .footer-text {
    white-space: normal;
  }
}
