/* ============================================================
   SAEKI QUEST AI — Official Stylesheet v2.0
   広島県立佐伯高等学校 総合的な探究の時間
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700;900&family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

/* ── Color Variables ── */
:root {
  --navy:           #162038;
  --navy-mid:       #1E2E4A;
  --navy-light:     #2C4268;
  --gold:           #C9A83C;
  --gold-light:     #DFC060;
  --gold-dark:      #8B7220;
  --school-blue:    #5B9DC9;
  --blue-light:     #A8CDE8;
  --blue-pale:      #E8F3FA;
  --cream:          #F5EFE0;
  --parchment:      #E8DFC8;
  --parchment-dark: #D4C8A8;
  --ink:            #0D0B08;
  --ink-mid:        #3A3228;
  --muted:          #7A7060;
  --green:          #2E7D52;
  --red:            #C0392B;
  --orange:         #D4860A;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Noto Sans JP', sans-serif;
  color: var(--ink); background: var(--cream);
  line-height: 1.7; min-height: 100vh;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-dark); }
input, textarea, select, button { font-family: 'Noto Sans JP', sans-serif; font-size: 14px; }
input[type="text"], input[type="date"], input[type="password"], textarea, select {
  width: 100%; border: 1.5px solid var(--parchment-dark);
  border-radius: var(--r-sm); padding: 10px 12px;
  background: #fff; color: var(--ink);
  transition: border-color .2s, box-shadow .2s; outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--school-blue);
  box-shadow: 0 0 0 3px rgba(91,157,201,.15);
}
textarea { resize: vertical; min-height: 72px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

body.login-page {
  background: linear-gradient(160deg, var(--navy) 0%, #0D1826 55%, #1A2840 100%);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; position: relative; overflow: hidden;
}
body.login-page::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(201,168,60,.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(91,157,201,.06) 0%, transparent 50%),
    repeating-linear-gradient(0deg, transparent, transparent 60px, rgba(255,255,255,.012) 61px),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(255,255,255,.012) 61px);
  pointer-events: none;
}

.login-container { position: relative; z-index: 1; width: 100%; max-width: 420px; }

.login-brand { text-align: center; margin-bottom: 24px; }

.login-crest {
  width: 58px; height: auto; color: var(--gold);
  margin: 0 auto 14px; display: block;
  filter: drop-shadow(0 0 10px rgba(201,168,60,.35));
}

.login-school-name {
  font-size: 11px; font-family: 'Noto Serif JP', serif;
  color: rgba(255,255,255,.55); letter-spacing: 0.2em; margin-bottom: 10px;
}

.login-sq-logo {
  display: block; width: 260px; height: auto;
  margin: 0 auto 8px;
  filter: drop-shadow(0 2px 14px rgba(201,168,60,.45));
}

.login-tagline {
  display: block; width: 190px; height: auto; margin: 0 auto; opacity: 0.8;
}

.login-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--r-lg); padding: 28px 26px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4), 0 0 0 1px rgba(201,168,60,.2);
}
.login-card h2 {
  font-family: 'Noto Serif JP', serif; font-size: 14px; font-weight: 700;
  color: var(--navy); text-align: center; margin-bottom: 18px; letter-spacing: 0.06em;
}
.login-card label {
  display: block; font-size: 11.5px; font-weight: 700;
  color: var(--navy-mid); margin-bottom: 5px; letter-spacing: 0.06em;
}
.login-card .field-group { margin-bottom: 13px; }

.btn-login {
  display: block; width: 100%; padding: 13px; margin-top: 18px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--gold-light); border: none; border-radius: var(--r-sm);
  font-size: 15px; font-weight: 700; font-family: 'Noto Serif JP', serif;
  letter-spacing: 0.12em; cursor: pointer;
  transition: all .2s; box-shadow: 0 4px 16px rgba(22,32,56,.4);
}
.btn-login:hover {
  box-shadow: 0 6px 22px rgba(22,32,56,.5); transform: translateY(-1px);
}

.login-hint {
  margin-top: 14px; padding: 11px 14px;
  background: var(--blue-pale); border-radius: var(--r-sm);
  border-left: 3px solid var(--school-blue);
  font-size: 11px; color: var(--ink-mid);
}
.login-hint strong {
  display: block; color: var(--navy); margin-bottom: 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em;
}

.login-error {
  background: #FEE; border-left: 3px solid var(--red);
  padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--red); margin-bottom: 14px;
}

/* ============================================================
   APP HEADER
   ============================================================ */

.app-header {
  background: var(--navy);
  color: #fff; display: flex; align-items: center;
  padding: 0 16px; height: 52px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 14px rgba(0,0,0,.3);
  border-bottom: 2px solid var(--gold-dark);
}

.header-brand {
  display: flex; align-items: center; gap: 10px; flex: 1; text-decoration: none;
}

.header-crest {
  width: 28px; height: auto; color: var(--gold-light); flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(201,168,60,.2));
}

.header-brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.header-brand-sq {
  font-family: 'Noto Serif JP', serif; font-size: 16px; font-weight: 900;
  color: var(--gold-light); letter-spacing: 0.04em;
}

.header-brand-sub {
  font-size: 9px; color: rgba(255,255,255,.45);
  letter-spacing: 0.14em; font-weight: 300;
}

.header-ai-badge {
  background: var(--gold); color: var(--navy);
  font-size: 9px; font-weight: 700; padding: 2px 7px;
  border-radius: 10px; letter-spacing: 0.08em; margin-left: 2px;
}

.header-user {
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.header-user span { color: rgba(255,255,255,.85); font-weight: 500; }
.header-user a {
  color: var(--gold-light); font-size: 12px;
  padding: 4px 10px; border: 1px solid rgba(201,168,60,.35);
  border-radius: 4px; transition: all .2s;
}
.header-user a:hover {
  background: rgba(201,168,60,.15); color: var(--gold-light);
}

/* ============================================================
   NAVIGATION TABS
   ============================================================ */

.nav-tabs {
  background: var(--navy-mid); display: flex; padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}

.nav-tab {
  color: rgba(255,255,255,.5); font-size: 13px; font-weight: 500;
  padding: 11px 15px; border-bottom: 3px solid transparent;
  white-space: nowrap; transition: all .2s;
  letter-spacing: 0.02em; text-decoration: none;
}
.nav-tab:hover { color: rgba(255,255,255,.82); background: rgba(255,255,255,.05); }
.nav-tab.active {
  color: var(--gold-light); border-bottom-color: var(--gold);
  background: rgba(201,168,60,.08);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main-content {
  max-width: 900px; margin: 0 auto; padding: 20px 16px 48px;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: #fff; border-radius: var(--r-md);
  padding: 18px 20px; margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(22,32,56,.07);
  border: 1px solid var(--parchment);
  border-top: 3px solid var(--gold);
}

.card-title {
  font-family: 'Noto Serif JP', serif; font-size: 15px; font-weight: 700;
  color: var(--navy); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 10px; border-bottom: 1px solid var(--parchment);
}
.card-title .icon { font-size: 16px; }

/* ============================================================
   STAT ROW
   ============================================================ */

.stat-row {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px;
}

.stat-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border-radius: var(--r-md); padding: 18px 12px;
  text-align: center; color: #fff;
  box-shadow: 0 4px 16px rgba(22,32,56,.2);
  border-bottom: 3px solid var(--gold-dark);
}
.stat-number {
  font-family: 'Noto Serif JP', serif; font-size: 32px; font-weight: 900;
  color: var(--gold-light); line-height: 1;
}
.stat-label { font-size: 11px; color: rgba(255,255,255,.6); margin-top: 4px; }

/* ============================================================
   STUDENT CARDS
   ============================================================ */

.student-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(195px,1fr)); gap: 12px; }

.student-card {
  background: #fff; border: 1px solid var(--parchment);
  border-radius: var(--r-md); padding: 14px 15px;
  text-decoration: none; color: var(--ink);
  transition: all .2s; border-left: 4px solid var(--school-blue); display: block;
}
.student-card:hover {
  box-shadow: 0 6px 20px rgba(22,32,56,.12);
  transform: translateY(-2px); border-left-color: var(--gold); color: var(--ink);
}
.student-name {
  font-family: 'Noto Serif JP', serif; font-size: 15px; font-weight: 700;
  color: var(--navy); margin: 6px 0 4px;
}
.student-theme { font-size: 12px; color: var(--ink-mid); line-height: 1.4; margin-bottom: 6px; }
.student-meta { font-size: 11px; color: var(--muted); }

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 12px; letter-spacing: 0.04em;
}
.badge-navy    { background: var(--navy); color: #fff; }
.badge-blue    { background: var(--school-blue); color: #fff; }
.badge-gold    { background: var(--gold); color: var(--navy); }
.badge-green   { background: #2E7D52; color: #fff; }
.badge-gray    { background: #9E9E9E; color: #fff; }
.badge-red     { background: var(--red); color: #fff; }
.badge-parchment { background: var(--parchment); color: var(--navy); }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 18px; border-radius: var(--r-sm);
  font-weight: 700; font-size: 13px; cursor: pointer;
  border: none; transition: all .2s;
  text-decoration: none; letter-spacing: 0.03em;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--gold-light); box-shadow: 0 3px 10px rgba(22,32,56,.3);
}
.btn-primary:hover { box-shadow: 0 5px 16px rgba(22,32,56,.4); color: var(--gold-light); }

.btn-secondary {
  background: var(--parchment); color: var(--navy);
  border: 1px solid var(--parchment-dark);
}
.btn-secondary:hover { background: var(--parchment-dark); color: var(--navy); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ============================================================
   FORMS
   ============================================================ */

.form-section { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--navy-mid); margin-bottom: 5px; letter-spacing: 0.04em;
}
.form-hint { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.required { color: var(--red); }

/* ============================================================
   AI CHAT
   ============================================================ */

.chat-window { min-height: 200px; padding: 4px 0; }

.chat-bubble-row { display: flex; gap: 10px; margin-bottom: 16px; }

.chat-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(22,32,56,.2);
}

.chat-bubble {
  background: var(--navy); color: rgba(255,255,255,.9);
  border-radius: 4px 12px 12px 12px; padding: 12px 16px;
  font-size: 13.5px; line-height: 1.7; max-width: 85%;
  box-shadow: 0 2px 8px rgba(22,32,56,.15);
}

.chat-bubble-user {
  background: var(--blue-pale); color: var(--ink);
  border-radius: 12px 4px 12px 12px; padding: 10px 14px;
  font-size: 13px; margin-left: auto; max-width: 75%;
  border: 1px solid var(--blue-light);
}

.chat-input-area { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.chat-input-area input { flex: 1; border-radius: 22px; padding: 11px 16px; }

.btn-send {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--gold-light); border: none; border-radius: 22px;
  padding: 11px 20px; font-weight: 700; cursor: pointer;
  font-size: 13px; white-space: nowrap; transition: all .2s;
}
.btn-send:hover { box-shadow: 0 4px 14px rgba(22,32,56,.3); transform: translateY(-1px); }

.quick-buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-btn {
  background: var(--parchment); border: 1px solid var(--parchment-dark);
  color: var(--navy); border-radius: 16px; padding: 6px 12px;
  font-size: 12px; font-weight: 500; cursor: pointer; transition: all .2s;
}
.quick-btn:hover { background: var(--navy); color: var(--gold-light); border-color: var(--navy); }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 7px; height: 7px; background: rgba(255,255,255,.5);
  border-radius: 50%; animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

/* ============================================================
   REFLECTION
   ============================================================ */

.quest-complete {
  text-align: center; padding: 32px 20px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: #fff; border-radius: var(--r-lg); margin-bottom: 16px;
  border-top: 3px solid var(--gold);
}
.quest-complete .icon { font-size: 40px; margin-bottom: 10px; }
.quest-complete h3 {
  font-family: 'Noto Serif JP', serif; font-size: 20px;
  color: var(--gold-light); margin-bottom: 8px;
}
.quest-complete p { color: rgba(255,255,255,.8); font-size: 14px; }

.reflection-item {
  border-left: 4px solid var(--school-blue); padding: 12px 14px;
  margin-bottom: 12px; background: #fff;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  box-shadow: 0 1px 4px rgba(22,32,56,.06);
}
.reflection-date { font-size: 12px; color: var(--navy); font-weight: 700; margin-bottom: 6px; }
.reflection-label {
  font-size: 11px; font-weight: 700; color: var(--gold-dark);
  letter-spacing: 0.05em; margin-top: 8px; margin-bottom: 2px;
}
.reflection-text { font-size: 13.5px; color: var(--ink-mid); line-height: 1.65; }
.feeling-stars { color: var(--gold); font-size: 12px; }

.feeling-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.feeling-btn {
  flex: 1; min-width: 58px;
  background: var(--parchment); border: 2px solid var(--parchment-dark);
  border-radius: var(--r-sm); padding: 8px 4px;
  cursor: pointer; text-align: center; transition: all .2s; font-size: 13px;
}
.feeling-btn:hover, .feeling-btn.selected {
  background: var(--navy); border-color: var(--gold);
  color: #fff; box-shadow: 0 3px 10px rgba(22,32,56,.2);
}

/* ============================================================
   TODO
   ============================================================ */

.todo-item {
  display: flex; align-items: flex-start; padding: 10px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--parchment);
  margin-bottom: 8px; background: #fff; transition: all .2s; gap: 10px;
}
.todo-item:hover { box-shadow: 0 2px 8px rgba(22,32,56,.08); }
.todo-item.done { background: var(--parchment); opacity: 0.75; }
.todo-body { flex: 1; }
.todo-title { font-size: 13.5px; font-weight: 500; color: var(--ink); margin-bottom: 3px; }
.todo-meta { font-size: 11.5px; color: var(--muted); }
.priority-高 { color: var(--red); font-weight: 700; }
.priority-中 { color: var(--orange); font-weight: 700; }
.priority-低 { color: var(--muted); }

/* ============================================================
   ERROR
   ============================================================ */

.error-msg {
  background: #FEE; border-left: 3px solid var(--red);
  padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--red); margin-bottom: 14px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
  .stat-number { font-size: 24px; }
  .student-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 14px 12px 32px; }
  .card { padding: 14px 14px; }
  .header-brand-sub { display: none; }
  .header-ai-badge { display: none; }
}
@media (max-width: 380px) {
  .student-grid { grid-template-columns: 1fr; }
}
