* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
header {
  padding: 12px 20px;
  border-bottom: 1px solid #333;
  background: #202020;
  flex-shrink: 0;
}
header h1 {
  margin: 0 0 10px 0;
  font-weight: 300;
  font-size: 1.4em;
}
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.controls input[type=search],
.controls select {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #e0e0e0;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.9em;
}
.controls input[type=search] {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}
.controls .count {
  color: #888;
  font-size: 0.85em;
  margin-left: auto;
}

/* --- Main layout: two panes --- */
main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left pane: list + letter strip */
#list-pane {
  width: 40%;
  min-width: 400px;
  display: flex;
  border-right: 1px solid #333;
  background: #1e1e1e;
}
#list-container {
  flex: 1;
  overflow-y: auto;
}
#letter-strip {
  width: 20px;
  background: #202020;
  border-left: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 0;
  font-size: 0.7em;
  user-select: none;
}
#letter-strip span {
  color: #666;
  cursor: pointer;
  padding: 1px 0;
  width: 100%;
  text-align: center;
}
#letter-strip span:hover {
  color: #e0e0e0;
  background: #2a2a2a;
}
#letter-strip span.disabled {
  color: #3a3a3a;
  cursor: default;
}
#letter-strip span.disabled:hover {
  background: transparent;
  color: #3a3a3a;
}

/* Cart list */
#cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid #262626;
  cursor: pointer;
  transition: background 0.1s;
}
.cart-row:hover {
  background: #262626;
}
.cart-row.selected {
  background: #2d4a5c;
}
.cart-row .thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 3px;
  background: #333;
}
.cart-row .fields {
  flex: 1;
  min-width: 0;             /* enables ellipsis on flex children */
  display: flex;
  gap: 10px;
  font-size: 0.85em;
  align-items: baseline;
  overflow: hidden;
  white-space: nowrap;
}
.cart-row .num {
  color: #888;
  font-family: monospace;
  font-size: 0.85em;
  flex-shrink: 0;
}
.cart-row .title {
  color: #e0e0e0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 2;
  min-width: 0;
}
.cart-row .artist {
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1.5;
  min-width: 0;
}
.cart-row .album {
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1.5;
  min-width: 0;
}
.cart-row .group {
  display: inline-block;
  background: #3a3a3a;
  color: #ccc;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.75em;
  flex-shrink: 0;
}

/* Right pane: detail */
#detail-pane {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #1a1a1a;
}
#detail-content .loading,
#detail-content .empty-prompt {
  color: #888;
  font-style: italic;
}

/* Default (no selection) summary view */
.summary-header {
  font-size: 1.1em;
  margin: 0 0 15px 0;
  font-weight: 300;
  color: #ccc;
}
.summary-stats {
  display: flex;
  gap: 25px;
  margin-bottom: 25px;
  padding: 15px;
  background: #222;
  border-radius: 6px;
}
.summary-stats .stat {
  display: flex;
  flex-direction: column;
}
.summary-stats .num {
  font-size: 1.8em;
  font-weight: 300;
  color: #e0e0e0;
}
.summary-stats .label {
  font-size: 0.75em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.summary-stats .stat.warn .num { color: #e6a15c; }

.group-list {
  border-top: 1px solid #2a2a2a;
  padding-top: 15px;
}
.group-list h3 {
  margin: 0 0 10px 0;
  font-size: 0.9em;
  color: #888;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.group-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.group-list th,
.group-list td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #262626;
}
.group-list th {
  color: #888;
  font-weight: 400;
  font-size: 0.8em;
  text-transform: uppercase;
}
.group-list td.missing.has-missing {
  color: #e6a15c;
  font-weight: 500;
}
.group-list td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Selected-cart detail view */
.detail-artwork {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: #333;
  display: block;
  margin: 0 auto 20px auto;
}
.detail-meta {
  max-width: 500px;
  margin: 0 auto;
}
.detail-meta h2 {
  margin: 0 0 4px 0;
  font-weight: 400;
  font-size: 1.3em;
}
.detail-meta .artist-line {
  color: #aaa;
  margin: 0 0 15px 0;
}
.detail-meta dl {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 15px;
  margin: 15px 0;
  font-size: 0.9em;
}
.detail-meta dt {
  color: #888;
  text-transform: uppercase;
  font-size: 0.75em;
  letter-spacing: 0.05em;
  align-self: center;
}
.detail-meta dd {
  margin: 0;
  color: #ddd;
}
.detail-actions {
  max-width: 500px;
  margin: 20px auto 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-actions button {
  background: #2d4a5c;
  border: 1px solid #3a5f75;
  color: #e0e0e0;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}
.detail-actions button:hover {
  background: #3a5f75;
}
.detail-actions button:disabled {
  background: #2a2a2a;
  border-color: #333;
  color: #666;
  cursor: not-allowed;
}

.upload-status {
  max-width: 500px;
  margin: 10px auto 0 auto;
  font-size: 0.85em;
  min-height: 1.2em;
}
.upload-status.busy  { color: #ccc; }
.upload-status.ok    { color: #7bc47f; }
.upload-status.error { color: #e66; }
