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

:root {
  --bg:        #F2F2F7;
  --white:     #FFFFFF;
  --ink:       #1A1A1A;
  --ink2:      #3C3C43;
  --muted:     #8E8E93;
  --line:      #E5E5EA;
  --blue:      #007AFF;
  --red:       #FF3B30;
  --purple:    #7B5EFF;

  --c-data:     #C9B8FF;
  --c-project:  #CAEF00;
  --c-resource: #1E3166;
  --c-notice:   #F04E37;
  --c-download: #FF8C42;
  --c-cases:    #17A589;

  --card-h:    150px;
  --card-step: 108px;   /* visible height per card (except last) */

  font-family: "SF Pro Display","SF Pro Text","PingFang SC",-apple-system,"Helvetica Neue",sans-serif;
  -webkit-font-smoothing: antialiased;
}

html, body { height: 100%; background: var(--bg); }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ── LOGIN ─────────────────────────────────────────────────── */
.login-shell {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--white); border-radius: 28px;
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.08);
  display: grid; gap: 28px;
}
.login-brand { text-align: center; display: grid; gap: 8px; }
.login-kicker {
  font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; font-weight: 700; color: var(--muted);
}
.login-brand h1 {
  font-size: 2.6rem; font-weight: 800;
  letter-spacing: -.06em; color: var(--ink); line-height: 1;
}
.login-brand p { color: var(--muted); font-size: 14px; line-height: 1.5; }
#login-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--ink2); }
.field input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 13px 16px; font: inherit; font-size: 16px; color: var(--ink);
  background: #FAFAFA; outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}
.field input:focus {
  border-color: var(--blue); background: var(--white);
  box-shadow: 0 0 0 4px rgba(0,122,255,.1);
}
.login-error { color: var(--red); font-size: 13px; }
#login-form button[type=submit] {
  width: 100%; padding: 15px; background: var(--ink); color: var(--white);
  border: none; border-radius: 16px; font: inherit; font-size: 16px;
  font-weight: 600; margin-top: 4px;
  transition: opacity 160ms, transform 160ms;
}
#login-form button[type=submit]:hover  { opacity: .88; transform: translateY(-1px); }
#login-form button[type=submit]:active { opacity: .76; transform: none; }

/* ── APP SHELL ─────────────────────────────────────────────── */
.app-shell {
  width: 100%; height: 100dvh; max-width: 480px; margin: 0 auto;
  background: var(--bg); display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* ── HEADER ────────────────────────────────────────────────── */
.app-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(env(safe-area-inset-top,0px) + 36px) 20px 12px;
  flex-shrink: 0; background: var(--bg);
}
.app-greeting {
  font-size: 12px; font-weight: 500; color: var(--muted);
  letter-spacing: .01em; margin-bottom: 2px;
}
.app-title {
  font-size: 26px; font-weight: 800;
  letter-spacing: -.05em; color: var(--ink);
}
.header-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); border: none; color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 160ms, opacity 160ms;
}
.header-btn:hover  { transform: scale(1.06); }
.header-btn:active { opacity: .76; transform: scale(.94); }

/* ── SCROLLABLE CONTENT ────────────────────────────────────── */
.app-content {
  flex: 1; overflow-y: auto; padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}
.app-content::-webkit-scrollbar { display: none; }
.content-bottom-pad { height: 16px; }

/* ── SCHEDULE CARD ─────────────────────────────────────────── */
.schedule-card {
  background: var(--white); border-radius: 20px;
  padding: 14px 16px; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.sch-header {
  display: flex; justify-content: space-between; align-items: center;
}
.sch-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.sch-date { font-size: 11px; color: var(--muted); }

/* Week row */
.week-row { display: flex; justify-content: space-between; align-items: center; }
.day-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; flex: 1; padding: 2px 0;
  -webkit-tap-highlight-color: transparent;
}
.day-label { font-size: 10px; color: var(--muted); line-height: 1; }
.day-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--ink);
  transition: background 160ms;
}
.day-btn.today .day-num   { background: var(--blue); color: #fff; }
.day-btn.sel:not(.today) .day-num { background: var(--line); }
.day-btn.weekend .day-label       { color: var(--red); }
.day-btn.weekend:not(.today) .day-num { color: var(--red); }
.todo-list { list-style: none; display: grid; gap: 6px; }
.todo-item {
  display: flex; align-items: center; gap: 8px;
}
.todo-item input[type=checkbox] {
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--line); flex-shrink: 0;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background: var(--white); transition: background 160ms, border-color 160ms;
  position: relative;
}
.todo-item input[type=checkbox]:checked {
  background: var(--blue); border-color: var(--blue);
}
.todo-item input[type=checkbox]:checked::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2.5 6l2.5 2.5 4.5-5' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
}
.todo-item span {
  font-size: 13px; color: var(--ink); line-height: 1.3;
  flex: 1; cursor: pointer;
}
.todo-item.done span { color: var(--muted); text-decoration: line-through; }
.todo-add-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: none; padding: 4px 0;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--blue);
  margin-top: 6px;
}

/* ── SEARCH BAR ────────────────────────────────────────────── */
.search-bar {
  height: 38px; background: var(--white); border-radius: 19px;
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05); margin-bottom: 12px;
}
.search-icon { color: var(--muted); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; background: transparent;
  font: inherit; font-size: 14px; color: var(--muted); outline: none;
}
.search-bar input::placeholder { color: var(--muted); }

/* ── CARDS STACK ───────────────────────────────────────────── */
.cards-stack {
  position: relative;
  height: calc(var(--card-step) * 5 + var(--card-h));
}
.module-card {
  position: absolute; left: 0; right: 0; height: var(--card-h);
  border-radius: 22px; padding: 18px 16px 18px 20px;
  display: flex; align-items: flex-start; justify-content: space-between;
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  transition: transform 200ms cubic-bezier(.34,1.56,.64,1);
  cursor: pointer; overflow: hidden;
}
/* Decorative texture circles */
.module-card::before, .module-card::after {
  content: ""; position: absolute; border-radius: 50%;
  pointer-events: none;
}
.module-card::before {
  width: 90px; height: 90px;
  right: 12px; top: -18px;
  background: rgba(255,255,255,.09);
}
.module-card::after {
  width: 130px; height: 130px;
  right: 30px; top: 28px;
  background: rgba(255,255,255,.05);
}
.module-card:hover  { transform: translateY(-3px); }
.module-card:active { transform: translateY(0) scale(.99); }

.card-data     { top: calc(var(--card-step) * 0); z-index:1; background: var(--c-data); }
.card-project  { top: calc(var(--card-step) * 1); z-index:2; background: var(--c-project); }
.card-resource { top: calc(var(--card-step) * 2); z-index:3; background: var(--c-resource); }
.card-notice   { top: calc(var(--card-step) * 3); z-index:4; background: var(--c-notice); }
.card-download { top: calc(var(--card-step) * 4); z-index:5; background: var(--c-download); }
.card-cases    { top: calc(var(--card-step) * 5); z-index:6; background: var(--c-cases); }

.card-content  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-name {
  font-size: 20px; font-weight: 800; letter-spacing: -.04em;
  color: var(--ink); line-height: 1.1;
}
.card-en {
  font-size: 10px; letter-spacing: .1em; font-weight: 600;
  color: rgba(0,0,0,.38); margin-bottom: 8px;
}
.card-resource .card-name, .card-notice .card-name,
.card-cases    .card-name { color: #fff; }
.card-resource .card-en  { color: rgba(255,255,255,.48); }
.card-notice   .card-en  { color: rgba(255,255,255,.62); }
.card-cases    .card-en  { color: rgba(255,255,255,.62); }

.card-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: rgba(255,255,255,.65); color: var(--ink); white-space: nowrap;
}
.card-resource .pill, .card-notice .pill, .card-cases .pill {
  background: rgba(255,255,255,.2); color: #fff;
}

.card-arrow {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.4); display: flex;
  align-items: center; justify-content: center; color: var(--ink);
  flex-shrink: 0; margin-top: 2px;
  transition: background 160ms, transform 160ms;
}
.card-arrow:hover  { background: rgba(255,255,255,.62); transform: scale(1.08); }
.card-arrow:active { transform: scale(.94); }
.card-resource .card-arrow, .card-notice .card-arrow, .card-cases .card-arrow {
  background: rgba(255,255,255,.18); color: #fff;
}
.card-resource .card-arrow:hover, .card-notice .card-arrow:hover, .card-cases .card-arrow:hover {
  background: rgba(255,255,255,.3);
}

/* ── CHAT BAR ──────────────────────────────────────────────── */
.chat-bar {
  margin: 10px 16px 8px;
  height: 44px; background: var(--white); border-radius: 22px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.07); flex-shrink: 0;
}
.chat-icon { color: var(--muted); flex-shrink: 0; }
.chat-input {
  flex: 1; border: none; background: transparent;
  font: inherit; font-size: 14px; color: var(--ink); outline: none; cursor: pointer;
}
.chat-input::placeholder { color: #C7C7CC; }
.chat-send {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); border: none; color: var(--white);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity 160ms, transform 160ms;
}
.chat-send:hover  { opacity: .88; transform: scale(1.06); }
.chat-send:active { opacity: .76; transform: scale(.94); }

/* ── BOTTOM NAV ────────────────────────────────────────────── */
.bottom-nav {
  display: flex; align-items: center; justify-content: center; gap: 72px;
  height: 60px; background: var(--white); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom,0px); flex-shrink: 0;
}
.nav-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; padding: 6px 14px; border-radius: 10px;
  color: var(--ink2); transition: opacity 160ms;
}
.nav-tab svg   { stroke: var(--ink2); }
.nav-tab span  { font-size: 9px; font-weight: 500; }
.nav-tab:hover  { opacity: .7; }
.nav-tab:active { opacity: .5; }
.nav-tab.nav-logout       { color: var(--red); }
.nav-tab.nav-logout svg   { stroke: var(--red); }

/* ── CHAT MODAL ────────────────────────────────────────────── */
.chat-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,.38);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.chat-modal-inner {
  width: 100%; max-width: 480px; margin: 0 auto;
  height: 75dvh; background: var(--white);
  border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom,0px);
}
.chat-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.chat-modal-title { display: flex; align-items: center; gap: 10px; }
.chat-avatar {
  width: 36px; height: 36px; border-radius: 18px;
  background: #EDE8FF; display: flex; align-items: center; justify-content: center;
  color: var(--purple); flex-shrink: 0;
}
.chat-modal-title h3 { font-size: 15px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.chat-modal-title p  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.chat-modal-actions { display: flex; align-items: center; gap: 6px; }
.chat-action-btn {
  width: 32px; height: 32px; border-radius: 50%; background: var(--bg);
  border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 160ms, color 160ms;
}
.chat-action-btn:hover { background: var(--line); color: var(--ink); }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; background: var(--bg);
  border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 160ms;
}
.modal-close:hover { background: var(--line); }

/* Messages */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-messages::-webkit-scrollbar { display: none; }
.chat-msg { max-width: 85%; }
.chat-msg p {
  font-size: 14px; line-height: 1.65; padding: 11px 14px;
  border-radius: 16px; margin: 0; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.assistant p { background: var(--bg); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.user         { align-self: flex-end; }
.chat-msg.user p       { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }

/* Thinking animation */
.chat-msg .thinking { color: var(--muted); font-style: italic; }
.chat-msg .thinking::after { content: ""; animation: dots 1.2s steps(3,end) infinite; }
@keyframes dots {
  0%  { content: ""; }  33% { content: "."; }
  66% { content: ".."; } 100%{ content: "..."; }
}

/* History panel */
.chat-history-panel {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-history-panel::-webkit-scrollbar { display: none; }
.history-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.history-empty p { font-size: 13px; color: var(--muted); }
.history-list { list-style: none; display: grid; gap: 6px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-radius: 14px; padding: 12px 14px;
  cursor: pointer; gap: 12px;
  transition: background 160ms;
}
.history-item:hover { background: var(--line); }
.history-item-main { flex: 1; min-width: 0; }
.history-item-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.history-item-del {
  background: none; border: none; color: var(--muted); padding: 4px;
  border-radius: 6px; flex-shrink: 0; transition: color 160ms;
}
.history-item-del:hover { color: var(--red); }

/* Input area */
.chat-modal-input {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 12px; border-top: 1px solid var(--line); flex-shrink: 0;
}
.chat-modal-input input {
  flex: 1; border: 1.5px solid var(--line); border-radius: 20px;
  padding: 10px 14px; font: inherit; font-size: 16px; color: var(--ink);
  background: #FAFAFA; outline: none; transition: border-color 160ms;
}
.chat-modal-input input:focus { border-color: var(--blue); background: var(--white); }

/* Mic button */
.mic-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg); border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 160ms, color 160ms;
}
.mic-btn:hover { background: var(--line); color: var(--ink); }
.mic-btn.recording {
  background: rgba(255,59,48,.12); color: var(--red);
  animation: pulse-ring 1s ease infinite;
}
@keyframes pulse-ring {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,59,48,.3); }
  50%      { box-shadow: 0 0 0 6px rgba(255,59,48,.0); }
}

/* ── DESKTOP FRAME ─────────────────────────────────────────── */
@media (min-width: 480px) {
  body { background: #E0E0E5; }
  .app-shell {
    border-left: 1px solid rgba(0,0,0,.08);
    border-right: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 0 60px rgba(0,0,0,.1);
  }
  .login-shell { background: #E0E0E5; }
}

/* ── SMALL SCREEN (<380px height) ──────────────────────────── */
@media (max-height: 700px) {
  :root { --card-h: 130px; --card-step: 90px; }
  .app-title { font-size: 22px; }
  .sch-day   { font-size: 34px; }
  .bottom-nav { height: 52px; }
}
