/* === Uncommon Sense Brand Tokens === */
:root {
  --charcoal: #2D2D2D;
  --charcoal-light: #3a3a3a;
  --amber: #F5A623;
  --amber-hover: #e0950e;
  --amber-light: rgba(245, 166, 35, 0.1);
  --white: #ffffff;
  --off-white: #f7f7f5;
  --grey-100: #f0efed;
  --grey-200: #e0dfdd;
  --grey-300: #ccc;
  --grey-500: #888;
  --grey-700: #555;
  --text: #2D2D2D;
  --error: #c0392b;
  --radius: 4px;
  --radius-lg: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--off-white);
  color: var(--text);
  line-height: 1.6;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.screen { display: none; }
.screen.active { display: flex; }

#login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--charcoal);
  flex-direction: column;
}

.login-box {
  background: var(--white);
  padding: 2.5rem 2.5rem 2rem;
  border-radius: var(--radius-lg);
  text-align: center;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
}

.login-divider {
  width: 40px;
  height: 3px;
  background: var(--amber);
  margin: 0 auto 1.5rem;
  border: none;
}

.login-box h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.login-box .subtitle {
  color: var(--grey-500);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.login-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  font-family: inherit;
  transition: border-color 0.2s;
  background: var(--off-white);
}

.login-box input:focus {
  outline: none;
  border-color: var(--amber);
  background: var(--white);
}

.login-box button {
  width: 100%;
  padding: 0.75rem;
  background: var(--charcoal);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: background 0.2s;
  margin-top: 0.25rem;
}

.login-box button:hover {
  background: var(--charcoal-light);
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.hidden { display: none !important; }

/* ============================================
   APP LAYOUT
   ============================================ */
#app-screen {
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: var(--charcoal);
  color: var(--white);
  padding: 0.75rem 2rem 0;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.header-logo {
  height: 28px;
  display: block;
}

.logout-btn {
  color: var(--grey-500);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--grey-500);
  border-radius: var(--radius);
  transition: all 0.2s;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.logout-btn:hover {
  color: var(--amber);
  border-color: var(--amber);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0;
}

.tab {
  padding: 0.7rem 1.5rem;
  background: transparent;
  color: var(--grey-500);
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
  color: var(--white);
}

.tab.active {
  color: var(--white);
  border-bottom-color: var(--amber);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
main {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
}

/* --- Panels --- */
.panel { display: none; }
.panel.active { display: block; }

.panel h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--charcoal);
}

.panel-description {
  color: var(--grey-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--charcoal);
  letter-spacing: 0.01em;
}

.form-group input[type="text"],
.form-group textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--amber);
}

.radio-group {
  display: flex;
  gap: 1.5rem;
}

.radio-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.radio-group input[type="radio"] {
  accent-color: var(--amber);
}

/* --- Toggle button groups --- */
.platform-toggle,
.source-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  overflow: hidden;
}

.platform-btn,
.source-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  background: var(--white);
  color: var(--grey-700);
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.platform-btn + .platform-btn,
.source-btn + .source-btn {
  border-left: 1px solid var(--grey-200);
}

.platform-btn.active,
.source-btn.active {
  background: var(--charcoal);
  color: var(--white);
}

.platform-btn:hover:not(.active),
.source-btn:hover:not(.active) {
  background: var(--grey-100);
}

.source-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.source-btn:disabled:hover {
  background: var(--white);
}

/* --- Amends section --- */
.amends-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--grey-100);
}

.amends-section label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--charcoal);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

.amends-section textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  background: var(--white);
  transition: border-color 0.2s;
  margin-bottom: 0.75rem;
}

.amends-section textarea:focus {
  outline: none;
  border-color: var(--amber);
}

/* --- Buttons --- */
.primary-btn {
  padding: 0.7rem 1.8rem;
  background: var(--charcoal);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: var(--charcoal-light);
}

.primary-btn:disabled {
  background: var(--grey-300);
  cursor: not-allowed;
}

.secondary-btn {
  padding: 0.5rem 1.2rem;
  background: var(--white);
  color: var(--charcoal);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  border-color: var(--amber);
  color: var(--amber-hover);
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* --- Results --- */
.result-box {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--amber);
}

.result-box h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--grey-100);
  color: var(--charcoal);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.content {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

.info-note {
  background: var(--amber-light);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--charcoal);
  margin-bottom: 1.25rem;
  border-left: 3px solid var(--amber);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(247, 247, 245, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--grey-200);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

#loading p {
  font-size: 0.9rem;
  color: var(--grey-700);
  font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 600px) {
  main { padding: 1.25rem; }
  header { padding: 0.75rem 1.25rem 0; }
  .tab { padding: 0.6rem 1rem; font-size: 0.75rem; }
  .login-box { margin: 0 1rem; padding: 2rem 1.5rem; }
  .header-logo { height: 22px; }
}
