:root {
  --bg: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text: #eee;
  --text-secondary: #a0a0b8;
  --border: rgba(255,255,255,0.08);
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

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

body {
  width: 380px;
  min-height: 200px;
  max-height: 560px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow-y: auto;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.logo-row { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 22px; }
h1 { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.header-actions { display: flex; gap: 4px; }

/* Icon button */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Usage bar */
.usage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: rgba(233,69,96,0.08);
  font-size: 11px;
  color: var(--text-secondary);
}
.upgrade-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 11px;
}
.upgrade-link:hover { color: var(--accent-hover); }

/* Length selector */
.length-selector {
  display: flex;
  gap: 6px;
  padding: 12px 16px 4px;
}
.length-btn {
  flex: 1;
  padding: 6px 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.length-btn:hover { border-color: var(--accent); color: var(--text); }
.length-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  padding: 8px 14px;
  color: var(--text);
  background: var(--bg-card);
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: #c0392b; color: #fff; }
.btn-full { width: 100%; }
.btn-sm { font-size: 11px; padding: 5px 10px; border-radius: 6px; }
.btn-summarize {
  margin: 12px 16px;
  width: calc(100% - 32px);
  padding: 12px;
  font-size: 15px;
  border-radius: 12px;
  position: relative;
}
.btn-summarize:disabled { opacity: 0.5; cursor: not-allowed; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
.result-area {
  margin: 0 16px 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.page-title {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.summary-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Error */
.error-area {
  margin: 0 16px 12px;
  padding: 10px 12px;
  background: rgba(192,57,43,0.15);
  border: 1px solid rgba(192,57,43,0.3);
  border-radius: var(--radius);
  color: #e74c3c;
  font-size: 12px;
}

/* Settings panel */
#settings-panel, #history-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 10;
  padding: 14px 16px;
  overflow-y: auto;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.settings-header h2 { font-size: 15px; }
.settings-body { display: flex; flex-direction: column; gap: 10px; }
.setting-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.hint { font-size: 11px; color: var(--text-secondary); }
.hint a { color: var(--accent); }

input[type="password"], input[type="text"], select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.api-key-row { display: flex; gap: 6px; align-items: center; }
.api-key-row input { flex: 1; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0b8'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
select option { background: var(--bg-secondary); }

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.history-item {
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--accent); }
.history-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-item-preview {
  font-size: 11px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.history-item-date {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 4px;
  opacity: 0.6;
}
.empty-state { text-align: center; padding: 40px 0; color: var(--text-secondary); }

/* Shortcut hint */
.shortcut-hint {
  text-align: center;
  padding: 8px 16px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.5;
}
kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: opacity 0.3s;
}

.hidden { display: none !important; }
