:root {
  --bg-porcelain: #E5F0FA;
  --bg-porcelain-light: #F0F6FC;
  --bg-white: #FFFFFF;
  
  --text-primary: #0F253E;
  --text-secondary: #436585;
  --text-muted: #7A9BB8;
  
  --border-subtle: #CBE0F2;
  --border-focus: #1E6BB8;
  
  --accent-blue: #1E6BB8;
  --accent-blue-hover: #165494;
  --accent-blue-light: #DCECF9;
  
  --status-green: #2E8B57;
  --status-red: #E53E3E;
  
  /* Neumorphic Shadows on Light Blue */
  --neu-flat: 8px 8px 20px rgba(135, 168, 198, 0.32), -8px -8px 20px #FFFFFF;
  --neu-flat-hover: 10px 10px 24px rgba(135, 168, 198, 0.40), -10px -10px 24px #FFFFFF;
  --neu-pressed: inset 3px 3px 6px rgba(135, 168, 198, 0.30), inset -3px -3px 6px #FFFFFF;
  --neu-sm: 4px 4px 10px rgba(135, 168, 198, 0.25), -4px -4px 10px #FFFFFF;
  --neu-card-border: 1px solid rgba(255, 255, 255, 0.85);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-porcelain);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 60px;
}

.app-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Header Bar */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  margin-bottom: 32px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
}

.brand-info h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.quota-box {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}

.passcode-btn, .history-toggle-btn {
  background: var(--bg-porcelain);
  border: none;
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.passcode-btn:hover, .history-toggle-btn:hover {
  color: var(--accent-blue);
  box-shadow: var(--neu-flat-hover);
}

.passcode-btn:active, .history-toggle-btn:active {
  box-shadow: var(--neu-pressed);
}

/* Control Console */
.console-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin-bottom: 32px;
}

.console-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.console-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.control-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-row {
  display: flex;
  gap: 14px;
  width: 100%;
}

.input-group-url {
  flex: 1;
  position: relative;
}

.neu-input {
  width: 100%;
  height: 52px;
  background: var(--bg-porcelain);
  border: none;
  box-shadow: var(--neu-pressed);
  border-radius: var(--radius-md);
  padding: 0 18px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.neu-input::placeholder {
  color: var(--text-muted);
}

.neu-input:focus {
  box-shadow: inset 4px 4px 8px rgba(165, 175, 190, 0.35), inset -4px -4px 8px #FFFFFF;
}

.input-group-type {
  width: 260px;
}

.neu-select {
  width: 100%;
  height: 52px;
  background: var(--bg-porcelain);
  border: none;
  box-shadow: var(--neu-flat);
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748B%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 10px;
  padding-right: 36px;
}

.neu-select:hover {
  box-shadow: var(--neu-flat-hover);
}

.neu-btn-primary {
  height: 52px;
  padding: 0 28px;
  background: var(--accent-blue);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 4px 4px 12px rgba(43, 108, 176, 0.35), -4px -4px 12px #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.neu-btn-primary:hover {
  background: var(--accent-blue-hover);
  box-shadow: 6px 6px 16px rgba(43, 108, 176, 0.42), -6px -6px 16px #FFFFFF;
}

.neu-btn-primary:active {
  transform: translateY(1px);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.neu-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Progress & Status */
.progress-card {
  display: none;
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin-bottom: 32px;
  text-align: center;
}

.spinner-wrap {
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

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

.progress-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.progress-step {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Results Dashboard */
.results-container {
  display: none;
  flex-direction: column;
  gap: 28px;
}

.toolbar-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.toolbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-status-badge {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--status-green);
  letter-spacing: 0.04em;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--bg-porcelain);
  border: none;
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.15s ease;
}

.action-btn:hover {
  box-shadow: var(--neu-flat-hover);
  color: var(--accent-blue);
}

.action-btn:active {
  box-shadow: var(--neu-pressed);
}

.action-btn-copy {
  background: var(--accent-blue);
  color: #FFFFFF;
}

.action-btn-copy:hover {
  background: var(--accent-blue-hover);
  color: #FFFFFF;
}

/* Overview Card */
.overview-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-xl);
  padding: 32px;
}

.overview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 16px;
}

.overview-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.3;
}

.overview-target {
  font-size: 13px;
  color: var(--accent-blue);
  text-decoration: none;
  word-break: break-all;
  display: inline-block;
  margin-top: 4px;
}

.overview-target:hover {
  text-decoration: underline;
}

/* Metrics Row */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.metric-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 16px;
}

.metric-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Media Cards Grid */
.media-section {
  margin-top: 28px;
}

.section-label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.media-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-img-wrap {
  width: 100%;
  height: 140px;
  background: var(--border-subtle);
  overflow: hidden;
}

.media-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.media-card:hover .media-img-wrap img {
  transform: scale(1.04);
}

.media-caption {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Content Cards */
.content-card {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-flat);
  border: var(--neu-card-border);
  border-radius: var(--radius-xl);
  padding: 32px;
}

.content-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.executive-summary-text {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.7;
}

.highlights-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.highlights-list li {
  position: relative;
  padding-left: 24px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.highlights-list li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  width: 7px;
  height: 7px;
  background: var(--accent-blue);
  border-radius: 2px;
}

/* Structured Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--neu-pressed);
  padding: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-porcelain);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(220, 226, 232, 0.6);
  color: var(--text-primary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Full Text Reader Box */
.reading-box {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-pressed);
  border-radius: var(--radius-md);
  padding: 24px;
  max-height: 380px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* History Drawer */
.history-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  height: 100vh;
  background: var(--bg-porcelain);
  box-shadow: -8px 0 24px rgba(165, 175, 190, 0.35);
  z-index: 1000;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.history-drawer.open {
  right: 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.history-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.history-close-btn {
  background: var(--bg-porcelain);
  border: none;
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--bg-porcelain);
  box-shadow: var(--neu-sm);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-item:hover {
  box-shadow: var(--neu-flat-hover);
}

.history-item:active {
  box-shadow: var(--neu-pressed);
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 30, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--bg-porcelain);
  box-shadow: 12px 12px 32px rgba(0, 0, 0, 0.25), -12px -12px 32px #FFFFFF;
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%;
  max-width: 440px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Toast Notifications */
.toast-msg {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1A202C;
  color: #FFFFFF;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.toast-msg.show {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .input-row {
    flex-direction: column;
  }
  .input-group-type {
    width: 100%;
  }
  .overview-header {
    flex-direction: column;
  }
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-actions {
    justify-content: stretch;
  }
  .action-btn {
    flex: 1;
    justify-content: center;
  }
}
