/* Lecture Diary — design system v2 */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1e46b8;
  --green: #16a34a;
  --green-dark: #15803d;
  --amber: #d97706;
  --red: #dc2626;
  --chip-bg: #f1f5f9;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 32px rgba(15,23,42,.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { scroll-padding-bottom: 180px; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg); color: var(--ink);
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh; font-size: 15.5px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.with-summary { padding-bottom: calc(168px + env(safe-area-inset-bottom)); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  gap: 8px;
  flex-wrap: nowrap;
}
.topbar .brand { flex-shrink: 0; }
.topbar .month-nav { flex: 1; min-width: 0; max-width: 180px; justify-content: center; }
.topbar .icon-link { flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-text { display: inline; }
@media (max-width: 360px) { .brand-text { display: none; } .month-nav #monthLabel { min-width: 88px; font-size: 13.5px; } }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.brand .logo svg { width: 17px; height: 17px; }
.month-nav { display: flex; align-items: center; gap: 2px; background: var(--chip-bg); border-radius: 11px; padding: 3px; }
.month-nav button {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-size: 19px; cursor: pointer; line-height: 1;
}
.month-nav button:active { background: #fff; color: var(--ink); }
#monthLabel { min-width: 104px; text-align: center; font-weight: 600; font-size: 14.5px; }
.top-actions { display: flex; gap: 6px; }
.icon-link {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.icon-link svg { width: 17px; height: 17px; }

main { max-width: 600px; margin: 0 auto; padding: 16px 14px 8px; }
.tab { display: none; animation: fadein .18s ease; }
.tab.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }

h2.sec {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); margin: 20px 0 10px; font-weight: 700;
}

/* ---------- form ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.field-row { display: flex; gap: 10px; }
.field { margin-bottom: 12px; flex: 1; min-width: 0; }
.field.grow { flex: 2; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 5px; letter-spacing: .01em;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 12px; font-size: 16px; font-family: inherit;
  border: 1.5px solid transparent; border-radius: 11px;
  background: var(--chip-bg); color: var(--ink); transition: border .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; background: #fff; border-color: var(--primary);
}
.daybox { flex: 0 0 92px; }
.day-val {
  padding: 12px 6px; text-align: center; font-weight: 700; font-size: 13px;
  color: var(--amber); background: #fef3e2; border-radius: 11px; letter-spacing: .03em;
}
.inline-add { display: flex; gap: 7px; }
.inline-add select { flex: 1; min-width: 0; }
.addbtn {
  flex: 0 0 48px; border: 1.5px dashed #cbd5e1; background: #fff; color: var(--ink-2);
  border-radius: 11px; font-size: 21px; font-weight: 500;
  cursor: pointer;
}
.addbtn:active { background: var(--chip-bg); }

.chip-label { width: 100%; font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin-bottom: -2px; }
#quickChips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.chip {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 550;
  cursor: pointer; box-shadow: var(--shadow-sm); font-family: inherit;
}
.chip b { color: var(--primary); font-weight: 650; }
.chip:active { background: var(--chip-bg); }

.net-banner {
  display: flex; justify-content: space-between; align-items: center;
  background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--green-dark);
  border-radius: 11px; padding: 12px 14px; margin-bottom: 12px; font-size: 15px;
}
.net-banner strong { font-size: 17px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; font-size: 15.5px; font-weight: 650;
  padding: 14px 18px; cursor: pointer; text-decoration: none; font-family: inherit;
  transition: filter .12s, opacity .12s;
}
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.big { width: 100%; font-size: 16.5px; padding: 15px; }
.btn.primary { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:active { filter: brightness(.92); }
.btn.excel { background: var(--primary); color: #fff; padding: 11px 16px; font-size: 14.5px; }
.btn.excel svg { width: 16px; height: 16px; }
.btn.ghost { background: transparent; color: var(--ink-2); margin-top: 6px; }
.hidden { display: none !important; }
.field-error { color: var(--red); font-size: 12px; font-weight: 600; min-height: 14px; margin-top: 4px; }
.field.invalid input, .field.invalid select { border-color: var(--red) !important; background: #fef2f2; }
.offline-banner { position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 29; background: #fef3c7; color: #92400e; text-align: center; padding: 6px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid #fde68a; }
.skeleton { background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 37%, #e2e8f0 63%); background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.field input:invalid, .field select:invalid { border-color: var(--red); }
.field select:invalid { color: var(--ink-3); }
.field select option { color: var(--ink); }
.field select option[value=""] { color: var(--ink-3); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.optional summary { cursor: pointer; font-size: 13.5px; color: var(--ink-3); margin-bottom: 10px; }


.form-card { padding: 18px; }
.form-section { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.form-section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); font-weight: 700; margin: 0 0 10px; }
.field-hint { font-size: 13px; font-weight: 600; color: var(--primary); min-height: 16px; }


/* ---------- custom select ---------- */
.custom-select-wrap { position: relative; }
.custom-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px; font-size: 16px; font-family: inherit; font-weight: 500;
  border: 1.5px solid transparent; border-radius: 11px; background: var(--chip-bg);
  color: var(--ink); cursor: pointer; text-align: left; min-height: 48px;
  transition: border .15s, background .15s;
}
.custom-select-trigger.placeholder { color: var(--ink-3); font-weight: 400; }
.custom-select-trigger:focus, .custom-select-trigger.open { outline: none; background: #fff; border-color: var(--primary); }
.custom-select-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.custom-select-arrow { width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; margin-left: 8px; transition: transform .18s; }
.custom-select-trigger.open .custom-select-arrow { transform: rotate(180deg); }
.select-sheet { max-height: 60vh; display: flex; flex-direction: column; }
.select-search { width: 100%; padding: 10px 12px; font-size: 15px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--chip-bg); margin-bottom: 10px; }
.select-search:focus { outline: none; border-color: var(--primary); background: #fff; }
.select-options { overflow-y: auto; max-height: 42vh; -webkit-overflow-scrolling: touch; }
.select-option { width: 100%; text-align: left; padding: 13px 12px; font-size: 15px; font-weight: 500; border: 0; border-bottom: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.select-option:last-child { border-bottom: 0; }
.select-option.selected { background: #eff6ff; color: var(--primary); font-weight: 650; }
.select-option:active { background: var(--chip-bg); }

@media (max-width: 360px) { .field-row { flex-direction: column; } }

.break-wrap { display: flex; align-items: center; gap: 8px; }
.break-wrap input { flex: 1; text-align: center; font-weight: 650; font-size: 18px; }
.break-btn { width: 44px; height: 44px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-size: 20px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.break-btn:active { background: var(--chip-bg); }

/* ---------- month list ---------- */
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 2px 8px; padding: 0 4px;
}
.day-head .d1 { font-weight: 700; font-size: 14px; color: var(--ink); }
.day-head .d1 span { color: var(--ink-3); font-weight: 550; }
.day-head .d2 { font-weight: 650; font-size: 13.5px; color: var(--green-dark); background:#f0fdf4; padding: 2px 9px; border-radius: 999px; }
.entry-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.entry-main { flex: 1; min-width: 0; }
.entry-line1 { font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.entry-line2 { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.entry-net { flex-shrink: 0; text-align: right; margin-right: 2px; }
.entry-net b {
  font-size: 15px; color: var(--green-dark); background: #f0fdf4;
  padding: 4px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.iconbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  width: 36px; height: 36px; flex-shrink: 0; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.iconbtn.del { color: var(--red); }
.empty { text-align: center; color: var(--ink-3); padding: 48px 24px; font-size: 15px; line-height: 1.65; }
.empty svg { width: 44px; height: 44px; color: #cbd5e1; margin-bottom: 10px; }

/* ---------- summary bar ---------- */
.summary-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: min(572px, calc(100% - 24px));
  background: var(--ink); color: #fff; border-radius: 16px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 18px; z-index: 25; box-shadow: var(--shadow-lg);
}
.sum-hrs { font-size: 12.5px; opacity: .75; font-weight: 550; letter-spacing: .02em; }
.sum-amt { font-size: 19px; font-weight: 750; letter-spacing: -.01em; }
.summary-bar .btn.excel { background: var(--green); }

body.with-summary main { padding-bottom: 120px; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 26;
  height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; max-width: 100%;
}
.navbtn {
  flex: 1; border: 0; background: none; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit;
  padding-top: 6px;
}
.navbtn svg { width: 21px; height: 21px; }
.navbtn.active { color: var(--primary); }
.navbtn.active .navdot { opacity: 1; }
.navdot { width: 4px; height: 4px; border-radius: 99px; background: var(--primary); opacity: 0; }
.badge {
  position: absolute; top: 6px; right: 18%; left: auto; margin-left: 0;
  background: var(--amber); color: #fff; border-radius: 999px; font-size: 10.5px;
  padding: 1px 6px; font-weight: 700; min-width: 18px; text-align: center;
}
.navbtn { position: relative; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 480px) { .modal-overlay { align-items: center; } }
.modal {
  background: #fff; border-radius: 22px 22px 0 0; width: 100%; max-width: 420px;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 480px) { .modal { border-radius: 20px; margin-bottom: env(safe-area-inset-bottom); } }
.modal h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: -.01em; }
.modal input {
  width: 100%; padding: 13px 12px; font-size: 16.5px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: 11px; background: var(--chip-bg);
}
.modal input:focus { outline: none; border-color: var(--primary); background: #fff; }
.nb-hint { font-size: 13px; color: var(--green-dark); min-height: 18px; margin-top: 7px; font-weight: 600; }
.suggest-label { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 5px; font-weight: 600; }
.suggest-item {
  display: block; width: 100%; text-align: left; background: var(--chip-bg);
  border: 1px solid var(--line); color: var(--ink); border-radius: 10px;
  padding: 11px 13px; font-size: 14.5px; font-weight: 600; margin-bottom: 6px;
  cursor: pointer; font-family: inherit;
}
.suggest-item:active { background: #e2e8f0; }
.modal-actions { display: flex; gap: 9px; margin-top: 16px; }
.modal-actions .btn { flex: 1; padding: 13px; }
.modal-cancel { background: var(--chip-bg); color: var(--ink-2); }


/* ---------- time picker ---------- */
.time-field-wrap { position: relative; }
.time-field-wrap input[readonly] { cursor: pointer; background: var(--chip-bg); padding-right: 38px; }
.time-field-wrap input[readonly]:focus { background: #fff; }
.time-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; margin-top: 10px; }
.time-modal .time-preview { text-align: center; font-size: 36px; font-weight: 750; letter-spacing: -.02em; color: var(--primary); margin: 4px 0 16px; font-variant-numeric: tabular-nums; }
.time-grid { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.time-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.time-value { font-size: 28px; font-weight: 700; min-width: 64px; text-align: center; padding: 10px 0; background: var(--chip-bg); border-radius: 12px; font-variant-numeric: tabular-nums; }
.time-arrow { width: 48px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.time-arrow:active { background: var(--chip-bg); }
.time-label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.time-sep { font-size: 28px; font-weight: 700; color: var(--ink-3); padding-bottom: 18px; }
.period-col { gap: 8px; margin-left: 8px; }
.period-btn { width: 56px; height: 44px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font-size: 14px; font-weight: 650; color: var(--ink-2); cursor: pointer; }
.period-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }


/* ---------- date picker ---------- */
.date-modal .date-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.date-title { font-size: 16px; font-weight: 700; }
.date-arrow { width: 40px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 20px; color: var(--ink-2); cursor: pointer; }
.date-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.date-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 8px; }
.date-cell { height: 44px; border-radius: 10px; border: 1px solid transparent; background: #fff; font-size: 15px; font-weight: 600; color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.date-cell:active { background: var(--chip-bg); }
.date-cell.other { color: var(--ink-3); opacity: .45; }
.date-cell.today { border-color: var(--primary); color: var(--primary); }
.date-cell.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(140px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(14px); background: #1e293b; color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 550;
  opacity: 0; transition: all .22s; pointer-events: none; z-index: 70;
  max-width: 88vw; text-align: center; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
body.with-summary .toast { bottom: calc(188px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(88px + env(safe-area-inset-bottom)); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 24px; background:
  radial-gradient(800px 400px at 50% -10%, #dbeafe, transparent), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 26px; box-shadow: var(--shadow-md); text-align: center;
}
.login-logo {
  width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: var(--shadow-md);
}
.login-logo svg { width: 28px; height: 28px; }
.login-card h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card p { color: var(--ink-2); font-size: 14px; margin: 0 0 24px; }
.pin-input {
  width: 100%; padding: 15px; font-size: 24px; text-align: center; letter-spacing: .5em;
  font-family: inherit; border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--chip-bg); margin-bottom: 14px;
}
.pin-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.pin-error { color: var(--red); font-size: 13.5px; min-height: 18px; font-weight: 600; margin-bottom: 6px; }

@media (min-width: 480px) {
  .modal-overlay { align-items: center; padding: 20px; }
}

@media (max-width: 360px) { .pin-input { letter-spacing: .35em; } }

