/* ==========================================================================
   Fluency (v1) — Windows 11 light theme
   ========================================================================== */

:root {
  --accent: #0067c0;          /* Windows accent blue */
  --accent-hover: #005ba1;
  --accent-press: #004e89;
  --bg: #f3f3f3;              /* Fluent light background */
  --surface: #ffffff;
  --surface-2: #fafafa;
  --stroke: #e5e5e5;
  --stroke-strong: #d6d6d6;
  --text: #1b1b1b;
  --text-soft: #5c5c5c;
  --text-faint: #8a8a8a;
  --danger: #c42b1c;
  --danger-hover: #a82217;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --font: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont,
          system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* -------------------------------- Brand ---------------------------------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand.small { gap: 10px; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2b88d8, #0067c0);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.brand.small .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; }
.brand h1 { margin: 0; font-size: 26px; font-weight: 600; }
.brand-name { font-size: 17px; font-weight: 600; }
.brand-ver { font-size: 13px; font-weight: 600; color: var(--text-faint); margin-left: 8px; letter-spacing: 0.2px; }
.brand-sub { margin: 4px 0 20px; color: var(--text-soft); text-align: center; }

/* -------------------------------- Buttons -------------------------------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--stroke-strong);
  background: var(--surface);
  color: var(--text);
  padding: 7px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
}
.btn:hover { background: #f5f5f5; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }

.btn-subtle { background: var(--surface); }
.btn-subtle:hover { background: #f0f0f0; }

.btn-danger { color: var(--danger); border-color: #e6c4c0; }
.btn-danger:hover { background: #fdf3f2; border-color: var(--danger); }

.btn-block { width: 100%; margin-top: 6px; }
.btn-small { padding: 3px 10px; font-size: 12.5px; }

/* ------------------------------- Inputs ---------------------------------- */
.field-label { display: block; font-size: 12.5px; color: var(--text-soft); margin: 12px 0 5px; }
.field-label.inline { margin: 0 4px 0 0; }

.text-input, .select-input {
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  border-bottom-width: 2px;
  border-bottom-color: #a0a0a0;
}
.text-input:focus, .select-input:focus {
  outline: none;
  border-color: var(--stroke-strong);
  border-bottom-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 103, 192, 0.15);
}
.select-input { width: auto; min-width: 190px; cursor: pointer; }

/* --------------------------- Auth (login) screen ------------------------- */
.auth-screen {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 32px 28px;
}
.auth-card .brand { justify-content: center; }

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 8px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-soft);
  cursor: pointer;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.form-error, .work-error {
  color: var(--danger);
  background: #fdf3f2;
  border: 1px solid #f1cdc9;
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 12px;
  font-size: 13px;
}

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

.titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--stroke);
}
.titlebar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--text-soft); font-size: 13px; }

.options-bar, .profile-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--stroke);
}
.bar-spacer { width: 14px; }
.key-input { max-width: 340px; }
.key-status { font-size: 12.5px; color: #107c10; min-width: 46px; }
.options-note { font-size: 12px; color: var(--text-faint); margin-left: auto; }

/* ------------------------------- Workspace ------------------------------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 340px;
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 24px;
  min-height: 0;
}

.pane, .history {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-head, .history-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--stroke);
  background: var(--surface-2);
}

.pane-text {
  flex: 1;
  border: none;
  resize: none;
  padding: 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  outline: none;
  overflow: auto;
}
.pane-text.output { white-space: pre-wrap; }
.pane-text.output:empty::before {
  content: "Your improved text will appear here.";
  color: var(--text-faint);
}

.pane-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--stroke);
  background: var(--surface-2);
}

/* -------------------------------- History -------------------------------- */
.history { padding-bottom: 8px; }
.history-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.history-empty { padding: 20px 16px; color: var(--text-faint); font-size: 13px; text-align: center; }

.history-card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
  position: relative;
}
.history-card .hc-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--text-faint); margin-bottom: 8px;
}
.history-card .hc-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); margin: 6px 0 2px; }
.history-card .hc-original { color: var(--text-soft); font-size: 13px; }
.history-card .hc-improved { color: var(--text); font-size: 13.5px; }
.history-card .hc-original, .history-card .hc-improved { white-space: pre-wrap; word-break: break-word; }
.history-card .hc-delete {
  border: none; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.history-card .hc-delete:hover { background: #fdf3f2; color: var(--danger); }

/* New history cards slide/fade in and push the list down */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.history-card.entering { animation: cardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1); }

/* Small spinner used on the Say Better button */
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px; margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------- Style / preferences panel --------------------- */
.style-panel {
  padding: 14px 20px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--stroke);
}
.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1000px;
}
.style-title { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; }
.style-hint { font-weight: 400; font-size: 12px; color: var(--text-faint); }
.pref-rules { min-height: 60px; resize: vertical; margin-bottom: 10px; }
.style-guide { min-height: 150px; resize: vertical; margin: 6px 0 10px; line-height: 1.5; }
.style-actions { display: flex; align-items: center; gap: 10px; }
.save-prefs-row { margin-top: 10px; }
#save-prefs { margin-top: 4px; }

/* Output feedback toolbar */
.output-foot { flex-wrap: wrap; }
.fb-status { font-size: 12px; color: #107c10; }

/* Active (pressed) state for the toggle feedback buttons */
.output-foot .btn.on {
  background: #eaf3fb;
  border-color: #cfe3f5;
  color: var(--accent);
}
.output-foot .btn.on:hover { background: #dfeefb; }

/* Small "Undo" link shown right after a feedback action */
.fb-undo {
  border: none; background: transparent; cursor: pointer;
  color: var(--accent); font-family: inherit; font-size: 12px;
  text-decoration: underline; padding: 0 4px;
}
.fb-undo:hover { color: var(--accent-hover); }

/* History example markers */
.history-card .hc-badge {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  color: var(--accent); background: #eaf3fb; border: 1px solid #cfe3f5;
  border-radius: 999px; padding: 1px 8px; margin-right: 6px;
}
.history-card.is-example { border-color: #cfe3f5; box-shadow: 0 0 0 1px #eaf3fb inset; }
.hc-star {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 6px; border-radius: 6px;
  color: var(--text-faint);
}
.hc-star.on { color: #e3a008; }
.hc-star:hover { background: #f0f0f0; }
.hc-actions { display: flex; align-items: center; gap: 2px; }

/* ------------------------------ Responsive ------------------------------- */
@media (max-width: 1000px) {
  .app-screen { height: auto; overflow: visible; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: none; }
  .pane, .history { min-height: 300px; }
  .options-note { margin-left: 0; width: 100%; }
  .style-grid { grid-template-columns: 1fr; gap: 16px; }
}
