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

/* ── Variables ── */
:root {
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --bg:            #F7F6F3;
  --surface:       #FFFFFF;
  --border:        #D9DDD6;
  --border-accent: #BFD3C2;
  --text-primary:  #232826;
  --text-secondary:#4B4F4B;
  --text-muted:    #5C6D60;
  --accent:        #46774C;
  --accent-light:  #DCE8DA;
  --accent-border: #BFD3C2;
  --tag-bg:        #EEF2EC;
  --tag-text:      #4B4F4B;
  --section-label: #475651;
  --radius:        14px;
  --radius-sm:     6px;

  --star-s:    #7c3aed;
  --star-t:    #0369a1;
  --star-a:    #0f766e;
  --star-r:    #b45309;
  --star-bg-s: #f5f3ff;
  --star-bg-t: #f0f9ff;
  --star-bg-a: #f0fdfa;
  --star-bg-r: #fffbeb;
}

/* ── Global ── */
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 2rem 1rem 4rem;
  min-height: 100vh;
}

.page-header {
  max-width: 760px;
  margin: 0 auto 1rem;
}

.page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-header p {
  font-family: var(--font-serif);
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.cards {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

details.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

details.card:hover {
  border-color: var(--border-accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

details.card[open] {
  border-color: var(--border-accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

details.card > summary {
  list-style: none;
  cursor: pointer;
  padding: 1.25rem 1.5rem;
  outline: none;
  user-select: none;
}

details.card > summary::-webkit-details-marker {
  display: none;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.chevron {
  font-size: 1.4rem;
  color: var(--text-muted);
  line-height: 1;
  flex-shrink: 0;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
  margin-top: 1px;
}

details[open] .chevron {
  transform: rotate(270deg);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.tag {
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  position: relative;
  cursor: pointer;
}

.tag:hover {
  background: #e0e0d8;
}

.tag .delete-tag {
  margin-left: 0.3rem;
  font-size: 0.6rem;
  color: var(--text-muted);
  cursor: pointer;
}

.tag .delete-tag:hover {
  color: #ff0000;
}

.add-tag {
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px dashed var(--tag-text);
}

.add-tag:hover {
  background: #e0e0d8;
}

.edit-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  font-size: inherit;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
}

.card-preview {
  margin-top: 0.85rem;
}

.summary-text {
  white-space: pre-wrap;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.summary-bullet {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  gap: 0.4rem;
}

.bullet-arrow {
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 600;
  margin-top: 0.05em;
}

.link-row {
  margin-top: 0.85rem;
  display: flex;
  gap: 1rem;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  transition: background 0.15s, border-color 0.15s;
}

.source-link:hover {
  background: #d0e4ce;
  border-color: #a0c0a8;
}

/* ── Expanded ── */

.card-expanded {
  padding: 0 1.5rem 1.5rem;
}

.divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 1.25rem;
}

.section {
  margin-bottom: 1.4rem;
}

.section:last-child {
  margin-bottom: 0;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.section-body p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bullet-list li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: 1.1rem;
  position: relative;
}

.bullet-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* ── STAR ── */

.star-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@media (max-width: 560px) {
  .star-block {
    grid-template-columns: 1fr;
  }
}

.star-item {
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
}

.star-item:nth-child(1) { background: var(--star-bg-s); }
.star-item:nth-child(2) { background: var(--star-bg-t); }
.star-item:nth-child(3) { background: var(--star-bg-a); }
.star-item:nth-child(4) { background: var(--star-bg-r); }

.star-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.star-item:nth-child(1) .star-label { color: var(--star-s); }
.star-item:nth-child(2) .star-label { color: var(--star-t); }
.star-item:nth-child(3) .star-label { color: var(--star-a); }
.star-item:nth-child(4) .star-label { color: var(--star-r); }

.star-item p {
  font-size: 0.835rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── Arc ── */

.arc-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.arc-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.arc-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--section-label);
}

.arc-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Questions ── */

.question-item {
  border-left: 2px solid var(--border-accent);
  padding-left: 0.9rem;
  margin-bottom: 0.9rem;
}

.question-item:last-child {
  margin-bottom: 0;
}

.question-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 0.3rem;
}

.question-intent {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.45rem;
}

.answer-frames {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.answer-frames li {
  font-size: 0.835rem;
  color: var(--text-secondary);
  line-height: 1.55;
  padding-left: 1rem;
  position: relative;
}

.answer-frames li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-weight: 700;
}

/* ── Roles ── */

.role-item {
  margin-bottom: 0.75rem;
}

.role-item:last-child {
  margin-bottom: 0;
}

.role-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--section-label);
  margin-bottom: 0.35rem;
}

/* ── Edit Banner ── */
.edit-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1.5rem;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: space-between;
}

.edit-banner.visible {
  display: flex;
}

.edit-banner span {
  font-size: 0.85rem;
  font-weight: 500;
}

.edit-banner button {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-sans);
}

.edit-banner button:hover {
  background: rgba(255, 255, 255, 0.28);
}

body.edit-active {
  padding-top: 4rem;
}

/* ── Login Modal ── */
.login-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.login-modal.visible {
  display: flex;
}

.login-box {
  width: 360px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.login-field {
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.login-field input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-sans);
  outline: none;
  color: var(--text-primary);
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-error {
  color: #dc2626;
  font-size: 0.8rem;
  min-height: 1.2em;
  margin-bottom: 0.75rem;
}

.login-submit {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  font-weight: 500;
}

.login-submit:hover {
  background: #3a6640;
}

/* ── FirebaseUI Overrides ── */
.firebaseui-id-secondary-link {
  display: none !important;
}
.firebaseui-container {
  max-width: 100% !important;
  font-family: var(--font-sans) !important;
}

.firebaseui-form-actions .mdl-button--raised.mdl-button--colored {
  background: var(--accent) !important;
  font-family: var(--font-sans) !important;
}

.firebaseui-form-actions .mdl-button--raised.mdl-button--colored:hover {
  background: #3a6640 !important;
}

.firebaseui-link {
  color: var(--accent) !important;
}

.mdl-progress > .progressbar {
  background-color: var(--accent) !important;
}

/* ── Display Mode ── */
.display-tag {
  cursor: default;
}

.display-tag:hover {
  background: var(--tag-bg);
}

summary.no-expand {
  cursor: default;
}

.detail-row {
  margin-top: 0.75rem;
}

.detail-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
