* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface2: #2a2a2a;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #6c9bff;
  --green: #4caf50;
  --yellow: #ffc107;
  --red: #ef5350;
  --border: #333;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: 0;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
}

#settings-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Search form */
#search-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#search-form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
}

#search-form input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  background: var(--text-dim);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  cursor: pointer;
}

#search-form input:focus {
  border-color: var(--accent);
}

#search-form input::placeholder {
  color: var(--text-dim);
}

#author-row {
  display: none;
}

#author-row.visible {
  display: block;
}

#form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

#toggle-author {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

#lookup-btn {
  flex: 1;
  padding: 10px 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

#lookup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Tracking status */
#tracking {
  padding: 0 16px;
  margin-bottom: 8px;
  display: none;
}

#tracking.visible {
  display: block;
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.badge-tracked {
  background: rgba(76, 175, 80, 0.15);
  color: var(--green);
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.od-format-link {
  display: inline-block;
  padding: 4px 10px;
  margin: 2px 4px 2px 0;
  border-radius: 6px;
  background: var(--surface2);
  text-decoration: none;
  font-size: 13px;
}

.od-format-link:active {
  opacity: 0.7;
}

.section-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 4px;
}

#add-btn {
  padding: 8px 16px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

#add-btn:disabled {
  opacity: 0.5;
}

/* Book info (cover + description) */
#book-info {
  padding: 16px 0 0;
}

#book-cover {
  display: block;
  max-width: 180px;
  border-radius: 6px;
  margin: 0 auto 12px;
}

#book-description {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

/* Results */
#results {
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.result-card {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  gap: 12px;
  min-height: 52px;
}

.result-card:active {
  background: var(--surface2);
}

.result-service {
  width: 90px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}

.result-detail {
  flex: 1;
  font-size: 14px;
  min-width: 0;
}

.result-detail .sub {
  font-size: 12px;
  color: var(--text-dim);
}

.result-arrow {
  color: var(--text-dim);
  font-size: 16px;
  flex-shrink: 0;
}

.status-available { color: var(--green); }
.status-wait { color: var(--yellow); }
.status-owned { color: var(--green); font-weight: 600; }
.status-not-found { color: var(--text-dim); }
.status-error { color: var(--red); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Placeholder rows while loading */
.result-card.loading .result-detail {
  color: var(--text-dim);
}

/* Settings modal */
#settings-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

#settings-modal.visible {
  display: flex;
}

#settings-panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 360px;
}

#settings-panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

#settings-panel input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

#settings-panel button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Login screen */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

#login-screen h1 {
  font-size: 24px;
  margin-bottom: 24px;
}

#login-screen input {
  width: 100%;
  max-width: 300px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
  text-align: center;
}

#login-screen button {
  padding: 12px 32px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

#login-error {
  color: var(--red);
  font-size: 14px;
  margin-top: 8px;
}

#app-screen { display: none; }
