:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #ff2442;
  --accent-hover: #e01e39;
  --accent-soft: #fff1f3;
  --pending-bg: #fff7ed;
  --pending-text: #c2410c;
  --processed-bg: #ecfdf5;
  --processed-text: #047857;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: #f3f4f6;
  color: var(--text);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

/* Login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.brand-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.subtitle {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.topbar-title {
  font-weight: 600;
  font-size: 16px;
}

.topbar-tag {
  font-size: 11px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 999px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 10px;
}

.tab {
  border: none;
  background: transparent;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.badge {
  font-size: 11px;
  background: #e5e7eb;
  color: var(--text);
  padding: 1px 6px;
  border-radius: 999px;
}

.tab.active .badge {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-box input {
  padding: 8px 10px;
  font-size: 13px;
}

.item-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.item-card:hover {
  border-color: #d1d5db;
  background: #fafafa;
}

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

.item-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.item-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-url {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.item-actions {
  display: flex;
  gap: 6px;
}

.empty-list {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 16px;
}

/* Status Pill */
.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-pill.pending {
  background: var(--pending-bg);
  color: var(--pending-text);
}

.status-pill.processed {
  background: var(--processed-bg);
  color: var(--processed-text);
}

/* Main Panel */
.main-panel {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h2 {
  margin: 0;
  font-size: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

.extracted-preview {
  margin: 10px 0;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.preview-label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.preview-url {
  color: var(--accent);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-url.empty {
  color: var(--text-muted);
  font-weight: 400;
}

.add-extra-row {
  display: flex;
  gap: 10px;
}

.add-extra-row input {
  flex: 1;
}

.add-btn-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.feedback-text {
  margin-top: 10px;
  font-size: 13px;
  color: var(--danger);
}

/* Detail Card */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-title {
  margin: 0 0 16px;
  font-size: 17px;
}

.detail-field {
  margin-bottom: 14px;
}

.detail-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.url-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.url-row a {
  color: var(--accent);
  font-size: 14px;
  word-break: break-all;
}

.raw-text-box {
  margin: 0;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.empty-detail-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-body p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.code-block-label {
  font-size: 12px;
  font-weight: 600;
  margin: 10px 0 6px;
}

.code-block {
  margin: 0;
  padding: 12px;
  background: #111827;
  color: #f9fafb;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@media (max-width: 820px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
  }
  .topbar {
    padding: 0 14px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .topbar-tag {
    display: none;
  }
  .workspace {
    display: flex;
    flex-direction: column;
  }
  .main-panel {
    order: 1;
    padding: 12px;
    overflow-y: visible;
  }
  .sidebar {
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
  .item-list {
    overflow-y: visible;
  }
  .card {
    padding: 14px;
  }
  input[type="text"],
  input[type="password"],
  textarea {
    font-size: 16px;
  }
  .add-extra-row {
    flex-direction: column;
  }
  .add-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .add-btn-group .btn {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 14px;
  }
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    text-align: center;
  }
}
