/* ── Storage card UI ─────────────────────────────────────────────────────── */

.storage-stack {
  display: grid;
  gap: 0.85rem;
}

.storage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  overflow: hidden;
}

.storage-card.is-local {
  border-left: 3px solid rgba(125, 211, 252, 0.45);
}

.storage-card.is-editing {
  border-color: rgba(125, 211, 252, 0.35);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.12);
}

.storage-card-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  flex-wrap: wrap;
}

.storage-card-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.storage-card-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 0.125rem);
  background: var(--muted);
  color: var(--muted-foreground);
}

.storage-card-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.storage-card-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--foreground);
}

.storage-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.storage-card-usage {
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.storage-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.storage-card-actions form {
  min-width: 0;
  margin: 0;
}

/* View-mode summary */
.storage-card-summary {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0 1.75rem;
  padding: 0.65rem 1.1rem 0.9rem;
  border-top: 1px solid var(--border);
}

.storage-detail {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 8rem;
  max-width: 100%;
}

.storage-detail > span:first-child,
.storage-detail > code:first-child {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.storage-detail > span:last-child,
.storage-detail > code:last-child {
  font-size: 0.82rem;
  color: var(--foreground);
  word-break: break-all;
}

.storage-detail-test > span:last-child {
  font-size: 0.8rem;
}

.storage-detail-test.is-ok > span:last-child { color: #86efac; }
.storage-detail-test.is-err > span:last-child { color: #fca5a5; }

/* Edit-mode body */
.storage-card:not(.is-editing) .storage-card-body { display: none; }
.storage-card.is-editing .storage-card-summary { display: none; }

.storage-card-body {
  border-top: 1px solid var(--border);
  padding: 1rem 1.1rem;
}

.storage-card-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: end;
}

.storage-card-fields > *,
.storage-ops-grid > *,
.storage-result-row,
.storage-result-row summary > *,
.storage-result-detail > * {
  min-width: 0;
}

.storage-card-fields label {
  display: grid;
  gap: 0.28rem;
  color: var(--muted-foreground);
  font-size: 0.8rem;
}

.storage-card-fields label span {
  font-size: 0.72rem;
  color: var(--muted-foreground);
}

.storage-card-fields textarea {
  min-height: 5rem;
  resize: vertical;
}

.storage-card-fields .checkbox-field {
  align-self: center;
}

.storage-card-edit-bar {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .storage-card-fields {
    grid-template-columns: 1fr;
  }
}

.storage-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.6rem;
}

.storage-type-option {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 120ms ease, background 120ms ease;
}

.storage-type-option:hover {
  border-color: rgba(125, 211, 252, 0.35);
  background: color-mix(in srgb, var(--card) 80%, rgba(14, 116, 144, 0.3));
}

.storage-type-option svg {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--muted-foreground);
  margin-bottom: 0.2rem;
}

.storage-type-option strong {
  font-size: 0.88rem;
  font-weight: 650;
}

.storage-type-option span {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  line-height: 1.4;
}

.storage-ops-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.storage-op-card {
  display: grid;
  gap: 0.5rem;
  align-content: start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 94%, transparent);
}

.storage-op-card strong {
  color: var(--foreground);
  font-size: 0.9rem;
}

.storage-op-card span {
  color: var(--muted-foreground);
  font-size: 0.78rem;
  line-height: 1.45;
}

.storage-op-card .button {
  justify-self: start;
  margin-top: 0.15rem;
}

.storage-form-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.78rem;
  line-height: 1.45;
}

.storage-modal[hidden] {
  display: none;
}

.storage-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.storage-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.storage-modal-card {
  position: relative;
  z-index: 1;
  width: min(30rem, 100%);
  max-height: min(42rem, 90vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow, 0 1rem 2.5rem rgba(0, 0, 0, 0.35));
}

.storage-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.storage-speed-form,
.storage-results-list {
  display: grid;
  gap: 0.65rem;
  padding: 0.9rem;
}

.storage-results-page {
  padding: 0;
  margin-top: 1rem;
}

.storage-tests-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.storage-speed-option {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 90%, var(--muted));
  cursor: pointer;
}

.storage-speed-option span {
  display: grid;
  gap: 0.18rem;
}

.storage-speed-option small {
  color: var(--muted-foreground);
  font-size: 0.72rem;
  line-height: 1.35;
}

.storage-custom-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
}

.storage-custom-fields[hidden] {
  display: none;
}

.storage-custom-fields label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.76rem;
}

.storage-result-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 92%, transparent);
}

.storage-result-row summary {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  font-size: 0.78rem;
}

.storage-test-progress {
  display: grid;
  gap: 0.25rem;
  padding: 0 0.75rem 0.65rem;
}

.storage-test-progress-bar {
  height: 0.45rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
}

.storage-test-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: color-mix(in srgb, var(--primary) 70%, #86efac);
  transition: width 180ms ease;
}

.storage-test-progress small {
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.storage-result-status {
  justify-self: end;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.storage-result-status.is-done { color: #86efac; }
.storage-result-status.is-failed { color: #fca5a5; }
.storage-result-status.is-running { color: #fde68a; }

.storage-result-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0 0.75rem 0.75rem;
}

.storage-result-detail span {
  display: grid;
  gap: 0.12rem;
  color: var(--foreground);
  font-size: 0.76rem;
  min-width: 0;
}

.storage-result-detail strong {
  color: var(--muted-foreground);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.storage-result-error {
  grid-column: 1 / -1;
  color: #fca5a5 !important;
  word-break: break-word;
}

@media (max-width: 860px) {
  .storage-ops-grid {
    grid-template-columns: 1fr;
  }

  .storage-result-row summary,
  .storage-result-detail,
  .storage-custom-fields {
    grid-template-columns: 1fr;
  }

  .storage-result-status {
    justify-self: start;
  }
}
