@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@600;700&family=Sora:wght@400;500;600;700;800&display=swap');

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

:root {
  --green:        #00C853;
  --green-strong: #008534;
  --green-dark:   #006B2C;
  --green-light:  #E0F5E5;
  --text:         #111111;
  --text-muted:   #5C6470;
  --border:       #EBEBEB;
  --bg:           #F5F5F5;
  --white:        #FFFFFF;
}

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ─── Screens ─── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ─── Logo mark ─── */
.logo-edged { color: rgba(17,17,17,0.5); }
.logo-up    { color: var(--green); }

.logo-large {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 8px;
}

.logo-small {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

/* ─── Screen 1: Login ─── */
#screen-login {
  align-items: center;
  justify-content: center;
  background: var(--white);
}

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 320px;
  padding: 32px;
}

.app-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 32px;
}

#pin-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

#pin-input {
  width: 200px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.2em;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
  color: var(--text);
}

#pin-input:focus { border-color: var(--green-strong); }
#pin-input.error { border-color: #DC2626; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
.shake { animation: shake 0.5s ease-in-out; }

/* ─── Buttons ─── */
.btn-primary {
  background: var(--green-strong);
  color: var(--white);
  border: none;
  border-radius: 9999px;
  padding: 12px 32px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--green-dark); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 10px 24px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--text-muted); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  font-family: 'Sora', sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-full { width: 100%; }

/* ─── App header ─── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sprint-badge {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Screen 2: Input ─── */
.input-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px;
}

.form-card {
  background: var(--white);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.field-row {
  display: flex;
  gap: 16px;
}
.field-row .field-group { flex: 1; }

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

textarea,
input[type="text"],
input[type="number"],
select {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
  background: var(--white);
  transition: border-color 0.15s;
  resize: vertical;
}
textarea:focus,
input[type="text"]:focus,
input[type="number"]:focus,
select:focus { border-color: var(--green-strong); }

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235C6470' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── Screen 3: Processing ─── */
.processing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green-strong);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.processing-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* ─── Screen 4: Preview ─── */
.preview-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 20px;
  overflow-y: auto;
}

.preview-img-wrap {
  width: 100%;
  max-width: 900px;
}

.preview-img-wrap img {
  width: 100%;
  border-radius: 16px;
  display: block;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.preview-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-row-sm { margin-top: -4px; }

.tweet-section {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
}

.tweet-section label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tweet-section textarea {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  line-height: 1.6;
}

.btn-copy { align-self: flex-start; }

/* ─── Screenshot upload zone (Task 7) ─── */
.screenshot-zone-wrap { margin-bottom: 0; }

.screenshot-drop-area {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.screenshot-drop-area:hover,
.screenshot-drop-area.drag-hover {
  border-color: var(--green);
  background: rgba(224, 245, 229, 0.3);
}

.screenshot-drop-text {
  font-family: 'Sora', sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
}

.screenshot-drop-sub {
  font-family: 'Sora', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.screenshot-or-divider {
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin: 12px 0 20px;
}

/* ─── Photo upload dual-mode (Task 1) ─── */
.photo-or-divider {
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}

.photo-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.photo-filename {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.btn-upload {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: 'Sora', sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Swap Photo section (Task 2) ─── */
.swap-section {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}

.swap-label {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.swap-url-row,
.swap-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swap-url-row input { flex: 1; min-width: 0; }

.btn-swap {
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9999px;
  flex-shrink: 0;
}

.swap-error {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  color: #C62828;
}

/* ─── Tweet section actions (Task 7) ─── */
.tweet-section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── History ─── */
.history-link {
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #5C6470;
  text-decoration: none;
  cursor: pointer;
}
.history-link:hover { color: #111111; }

.history-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

.history-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #111111;
  margin-bottom: 20px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.history-card {
  background: #FFFFFF;
  border-radius: 16px;
  border: 1px solid #EBEBEB;
  overflow: hidden;
  cursor: pointer;
}

.history-card-img {
  width: 100%;
  aspect-ratio: 600/628;
  object-fit: cover;
  background: #F5F5F5;
}

.history-card-meta {
  padding: 12px;
}

.history-card-market {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #111111;
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-card-details {
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  color: #5C6470;
  margin-bottom: 8px;
}

.history-card-actions {
  display: flex;
  gap: 8px;
}

.history-btn-download {
  flex: 1;
  background: #008534;
  color: white;
  border: none;
  border-radius: 9999px;
  padding: 6px 12px;
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.history-btn-delete {
  background: #FEE2E2;
  color: #C62828;
  border: none;
  border-radius: 9999px;
  padding: 6px 12px;
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.history-empty {
  color: #5C6470;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

.history-loading {
  color: #5C6470;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  text-align: center;
  padding: 40px;
}

/* ─── Sprint 4d: Drop zone with submit button ─── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 32px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone-text {
  font-family: 'Sora', sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
}

.drop-zone-sub {
  font-family: 'Sora', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.drop-zone-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.btn-secondary-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 8px 16px;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-secondary-sm:hover { border-color: var(--green); color: var(--text); }

.btn-ghost-sm {
  background: transparent;
  border: none;
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  margin-top: 4px;
}

.btn-primary-full {
  width: 100%;
  background: var(--green-strong);
  color: var(--white);
  border: none;
  border-radius: 9999px;
  padding: 12px;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}
.btn-primary-full:hover { background: var(--green-dark); }

.drag-over {
  border-color: var(--green) !important;
  background: rgba(0, 200, 83, 0.05) !important;
}

/* ─── Sprint 4d: Staleness banner ─── */
.staleness-banner {
  max-width: 700px;
  margin: 0 auto 12px auto;
  padding: 10px 16px;
  border-radius: 10px;
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 500;
}
.banner-resolved {
  background: #FEE2E2;
  color: #C62828;
  border: 1px solid #FCA5A5;
}
.banner-changed {
  background: #FFF7ED;
  color: #92400E;
  border: 1px solid #FCD34D;
}

/* ─── URL input zone (Sprint 5b) ─── */
.url-input-zone {
  margin-bottom: 16px;
}
.url-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #EBEBEB;
  border-radius: 10px;
  font-family: 'Sora', sans-serif;
  font-size: 13px;
  color: #111111;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.url-input:focus {
  outline: none;
  border-color: #00C853;
}

/* ─── Saved session list (Sprint 5b) ─── */
.saved-list-section {
  max-width: 700px;
  margin: 24px auto 0 auto;
  padding: 0 16px;
}
.saved-list-header {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #5C6470;
  margin-bottom: 10px;
}
.saved-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saved-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFFFFF;
  border: 1px solid #EBEBEB;
  border-radius: 12px;
  padding: 10px 14px;
}
.saved-card-thumb {
  width: 60px;
  height: 63px;
  object-fit: cover;
  border-radius: 6px;
  background: #F5F5F5;
  flex-shrink: 0;
}
.saved-card-info {
  flex: 1;
  min-width: 0;
}
.saved-card-market {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #111111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.saved-card-tweet {
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  color: #5C6470;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.saved-dl-btn {
  background: #F5F5F5;
  border: 1px solid #EBEBEB;
  border-radius: 9999px;
  padding: 5px 12px;
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #5C6470;
  text-decoration: none;
  cursor: pointer;
}
.saved-dl-btn:hover {
  background: #E0F5E5;
  border-color: #00C853;
  color: #008534;
}
