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

:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --dim: #999;
  --border: #e0e0e0;
  --hover: #f0f0f0;
  --green: #2a7d2a;
  --red: #c43c3c;
}

body {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Menlo, monospace;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hidden { display: none !important; }

a { color: var(--text); }

/* Auth */
#auth-screen {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box h1 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.auth-box p {
  color: var(--dim);
  margin-bottom: 1.5rem;
}

.auth-box input {
  display: block;
  width: 200px;
  padding: 4px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  color: var(--text);
  outline: none;
  margin-bottom: 1rem;
}

.auth-box input:focus {
  border-color: var(--text);
}

.auth-box button {
  background: none;
  border: none;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-box button:hover { color: var(--text); }

/* Header */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

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

#view-tabs { display: flex; gap: 1rem; }

.tab {
  background: none;
  border: none;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}

.tab.active { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.tab:hover { color: var(--text); }

/* Platform Bar */
.platform-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.platform {
  background: none;
  border: none;
  font: inherit;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}

.platform.active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.platform:hover { color: var(--text); }

/* Prompt Section */
.prompt-section {
  margin-bottom: 1.5rem;
}

.prompt-section summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 12px;
  user-select: none;
  list-style: none;
}

.prompt-section summary::before { content: "+ "; }
.prompt-section[open] summary::before { content: "- "; }

.prompt-hint { display: none; }

#prompt-editor {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  color: var(--text);
  resize: vertical;
  outline: none;
  line-height: 1.6;
}

.prompt-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.prompt-actions button {
  background: none;
  border: none;
  font: inherit;
  font-size: 12px;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prompt-actions button:hover { color: var(--text); }

/* Model Bar */
.model-bar {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 12px;
}

.model-label { color: var(--dim); }

#model-select {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  font-size: 12px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  padding: 2px 0;
  -webkit-appearance: none;
}

.model-price { color: var(--dim); font-size: 11px; }

/* Input */
.input-section { margin-bottom: 1.5rem; }

#input-text {
  width: 100%;
  padding: 0.5rem 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  color: var(--text);
  resize: vertical;
  outline: none;
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

#input-text:focus { border-color: var(--text); }

/* Image Upload */
.image-area {
  margin-bottom: 0.75rem;
}

.image-drop {
  border: 1px dashed var(--border);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
  color: var(--dim);
  transition: border-color 0.15s;
}

.image-drop:hover,
.image-drop.dragover {
  border-color: var(--text);
  color: var(--text);
}

.image-preview {
  position: relative;
  display: inline-block;
}

.image-preview img {
  max-width: 120px;
  max-height: 80px;
  display: block;
  border: 1px solid var(--border);
}

#image-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.polish-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.vision-warn {
  font-size: 11px;
  color: var(--red);
}

#polish-btn {
  background: none;
  border: 1px solid var(--text);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  padding: 4px 16px;
}

#polish-btn:hover { background: var(--text); color: var(--bg); }
#polish-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Result */
#result-section { margin-top: 2rem; }

.result-block {
  margin-bottom: 1.5rem;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.result-header h3 {
  font-size: 12px;
  color: var(--dim);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 11px;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}

.copy-btn:hover { color: var(--text); }
.copy-btn.copied { color: var(--green); }

.result-content {
  white-space: pre-wrap;
  line-height: 1.8;
}

/* History */
.history-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.history-filters select {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  font: inherit;
  color: var(--text);
  outline: none;
  padding: 2px 0;
  cursor: pointer;
  -webkit-appearance: none;
}

.history-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.history-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
  font-size: 12px;
  color: var(--dim);
}

.history-meta-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.platform-tag { font-weight: 600; }

.status-badge {
  background: none;
  border: none;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}

.status-badge.posted { color: var(--green); }
.status-badge.not-posted { color: var(--red); }
.status-badge:hover { text-decoration: underline; text-underline-offset: 3px; }

.history-original {
  color: var(--dim);
  font-size: 12px;
  margin-bottom: 0.5rem;
}

.history-polished {
  white-space: pre-wrap;
  line-height: 1.7;
}

.history-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.history-actions button {
  background: none;
  border: none;
  font: inherit;
  font-size: 11px;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}

.history-actions button:hover { color: var(--text); }
.history-actions button.delete-btn:hover { color: var(--red); }

/* Usage inline (after polish) */
.usage-inline {
  font-size: 11px;
  color: var(--dim);
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.usage-inline span { margin-right: 1.5rem; }

/* Usage View */
.usage-section-title {
  font-size: 12px;
  font-weight: 400;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.5rem 0 0.75rem;
}

.usage-total {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.usage-stat {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 12px;
}

.usage-stat-label { color: var(--dim); }
.usage-stat-value { font-weight: 600; }
.usage-stat-value.cost { color: var(--red); }

.usage-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.usage-table th {
  text-align: left;
  font-weight: 400;
  color: var(--dim);
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

.usage-table td {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

.usage-table td:last-child,
.usage-table th:last-child { text-align: right; }

/* Loading */
@keyframes blink { 50% { opacity: 0; } }
.loading {
  display: inline;
  animation: blink 1s step-end infinite;
}
.loading::after { content: "..."; }
