:root{
  color-scheme:dark;
  --bg:#060814;
  --bg-2:#0b1020;
  --surface:rgba(17,22,37,.62);
  --surface-strong:rgba(20,25,42,.82);
  --surface-soft:rgba(255,255,255,.035);
  --line:rgba(255,255,255,.09);
  --line-strong:rgba(255,255,255,.14);
  --text:#f2f5ff;
  --muted:#a7aec3;
  --muted-2:#7f879f;
  --purple:#b4a6ff;
  --purple-strong:#7e6bff;
  --purple-deep:#5846d9;
  --green:#52dfb1;
  --red:#ff808d;
  --shadow:0 20px 50px rgba(0,0,0,.32);
  --glass:blur(24px) saturate(160%);
  --radius-xl:30px;
  --radius-lg:24px;
  --radius-md:18px;
  --safe-top:max(10px, env(safe-area-inset-top));
  --safe-bottom:max(12px, env(safe-area-inset-bottom));
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{scroll-behavior:smooth;max-width:100%;overflow-x:hidden;background:var(--bg)}
body{
  margin:0;
  color:var(--text);
  font:16px/1.45 -apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
  background:
    radial-gradient(900px 520px at -10% -10%, rgba(116,104,255,.28), transparent 55%),
    radial-gradient(650px 420px at 110% 12%, rgba(74,177,255,.14), transparent 48%),
    radial-gradient(700px 560px at 50% 118%, rgba(137,95,255,.14), transparent 44%),
    linear-gradient(180deg, #080b16 0%, #060914 52%, #050711 100%);
  min-height:100vh;
  max-width:100%;
  overflow-x:hidden;
}
body::before,
body::after{
  content:"";
  position:fixed;
  inset:auto;
  z-index:-1;
  pointer-events:none;
  filter:blur(70px);
  opacity:.7;
}
body::before{
  width:190px;height:190px;left:-40px;top:110px;
  background:rgba(119,94,255,.22);
}
body::after{
  width:180px;height:180px;right:-30px;top:280px;
  background:rgba(86,164,255,.16);
}
button,input,select,textarea{font:inherit}
button{cursor:pointer}
button:disabled{opacity:.45;cursor:not-allowed}
a{color:inherit}
small{font-size:13px}
.app{max-width:760px;margin:0 auto;padding:var(--safe-top) 10px calc(96px + var(--safe-bottom));position:relative;min-height:100vh}
header{
  position:sticky;
  top:var(--safe-top);
  z-index:20;
  display:flex;
  align-items:center;
  gap:14px;
  margin:0 4px 14px;
  padding:14px 16px;
  border-radius:28px;
  background:linear-gradient(180deg,rgba(23,28,43,.72),rgba(14,19,32,.58));
  border:1px solid rgba(255,255,255,.09);
  box-shadow:0 18px 36px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter:var(--glass);
  -webkit-backdrop-filter:var(--glass);
}
header strong{display:block;font-size:18px;letter-spacing:-.02em}
header small{display:block;color:var(--muted);margin-top:3px}
.logo{
  width:46px;height:46px;border-radius:16px;flex:0 0 46px;
  display:grid;place-items:center;
  color:white;
  background:linear-gradient(180deg, rgba(145,128,255,.95), rgba(98,84,225,.92));
  border:1px solid rgba(255,255,255,.14);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.14),0 16px 30px rgba(101,84,223,.28);
}
.logo-icon{width:24px;height:24px;display:block}
.pill{
  margin-left:auto;
  white-space:nowrap;
  border-radius:999px;
  padding:9px 12px;
  font-size:11px;
  letter-spacing:.04em;
  color:#d9d2ff;
  background:linear-gradient(180deg, rgba(122,103,255,.24), rgba(122,103,255,.12));
  border:1px solid rgba(169,154,255,.2);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.05);
}
main{padding:6px 6px 0;min-height:calc(100vh - 140px)}
.screen{display:none;animation:screenIn .22s ease}
.screen.active{display:block}
@keyframes screenIn{from{opacity:.3;transform:translateY(6px)}to{opacity:1;transform:none}}
h1{
  margin:0 0 8px;
  font-size:clamp(30px,7vw,44px);
  line-height:1.04;
  letter-spacing:-.04em;
}
h2,h3,b,strong{letter-spacing:-.02em}
.muted{color:var(--muted);margin:0 0 22px;line-height:1.5}
.caption,.section-title{font-size:12px;letter-spacing:.18em;color:#b8b0ff;font-weight:800;text-transform:uppercase}
.section-title{margin:0 0 14px;color:#8790aa}
.hero,.card,.item,.tile,form.card{
  position:relative;
  background:linear-gradient(180deg,rgba(20,25,42,.7),rgba(12,16,29,.62));
  border:1px solid rgba(255,255,255,.08);
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.045);
  backdrop-filter:var(--glass);
  -webkit-backdrop-filter:var(--glass);
}
.hero::before,.card::before,.item::before,.tile::before,dialog::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius:inherit;
  pointer-events:none;
  background:linear-gradient(180deg,rgba(255,255,255,.06),rgba(255,255,255,0) 28%);
  opacity:.8;
}
.hero{
  border-radius:32px;
  padding:24px 22px;
  margin:26px 0 32px;
  overflow:hidden;
  background:
    radial-gradient(520px 220px at 85% -5%, rgba(127,110,255,.28), transparent 42%),
    radial-gradient(300px 180px at -10% 110%, rgba(87,168,255,.12), transparent 48%),
    linear-gradient(180deg, rgba(22,27,46,.78), rgba(12,16,30,.68));
}
.hero h2{font-size:30px;line-height:1.06;margin:12px 0 10px}
.hero p{color:#c0c6d8;line-height:1.58;margin:0}
.linkbutton{
  margin-top:12px;
  background:transparent;
  border:0;
  color:#b9abff;
  padding:10px 0 0;
  font-size:17px;
  font-weight:600;
}
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.tile{
  min-height:164px;
  text-align:left;
  border-radius:28px;
  padding:20px 18px;
  display:flex;
  flex-direction:column;
  gap:10px;
  transition:transform .18s ease,border-color .18s ease,box-shadow .18s ease;
}
.tile:hover{transform:translateY(-1px);border-color:rgba(177,165,255,.18);box-shadow:0 22px 42px rgba(0,0,0,.26)}
.tile:active{transform:scale(.985)}
.tile b{font-size:22px;overflow-wrap:anywhere}
.tile small{color:var(--muted);line-height:1.45;font-size:15px}
.icon{
  width:48px;height:48px;border-radius:16px;display:grid;place-items:center;
  color:#d4cbff;
  background:linear-gradient(180deg, rgba(137,120,255,.22), rgba(106,89,225,.14));
  border:1px solid rgba(177,165,255,.18);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.06);
}
.svg-icon{width:22px;height:22px;display:block}
.date-nav{
  display:grid;
  grid-template-columns:46px minmax(0,1fr) 46px;
  align-items:center;
  gap:12px;
  margin:24px 0 20px;
}
.date-nav>div{
  min-width:0;
  padding:16px 14px;
  text-align:center;
  border-radius:22px;
  background:linear-gradient(180deg,rgba(20,25,42,.68),rgba(12,16,29,.56));
  border:1px solid rgba(255,255,255,.07);
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.045);
  backdrop-filter:var(--glass);
  -webkit-backdrop-filter:var(--glass);
}
.date-nav button{
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg,rgba(22,27,44,.74),rgba(13,16,28,.64));
  color:var(--text);
  border-radius:18px;
  width:46px;height:46px;
  font-size:28px;line-height:1;
  box-shadow:var(--shadow), inset 0 1px 0 rgba(255,255,255,.04);
  backdrop-filter:var(--glass);
  -webkit-backdrop-filter:var(--glass);
}
.date-nav strong{display:block;font-size:clamp(16px,4.7vw,24px);line-height:1.25}
.date-nav small{display:block;color:#b0a7ff;margin-top:5px}
.items{display:grid;gap:12px;margin-bottom:22px}
.card,.item{border-radius:28px;padding:20px;margin:0}
.item-head{display:flex;flex-wrap:wrap;align-items:center;gap:10px;justify-content:space-between;margin-bottom:10px}
.item h3{margin:0 0 10px;font-size:23px;overflow-wrap:anywhere}
.item p,.card p{color:var(--muted);line-height:1.56;margin:0 0 8px}
.item small{color:var(--muted)}
.time{color:#c2b8ff;font-size:14px;font-weight:600}
.badge{
  display:inline-flex;align-items:center;gap:6px;
  background:rgba(54,102,87,.28);
  color:var(--green);
  border:1px solid rgba(82,223,177,.18);
  border-radius:999px;
  padding:6px 10px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.badge.purple{
  background:rgba(121,102,247,.16);
  color:#c4b9ff;
  border-color:rgba(164,148,255,.18);
}
.actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:16px}
.actions button{
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  color:#d5daea;
  border-radius:14px;
  padding:10px 14px;
  font-weight:600;
}
.actions .danger{color:var(--red)}
.primary{
  display:block;width:100%;border:0;
  background:linear-gradient(180deg,#8978ff,#6a5be1);
  color:white;
  padding:17px 18px;
  border-radius:20px;
  font-size:18px;
  font-weight:800;
  letter-spacing:-.02em;
  box-shadow:0 18px 34px rgba(107,91,225,.28), inset 0 1px 0 rgba(255,255,255,.2);
}
.hint{font-size:14px;color:var(--muted);line-height:1.6;margin:-4px 0 0}
.empty{color:var(--muted-2);text-align:center;padding:44px 20px;line-height:1.65}
.form,.modal-form{display:grid;gap:16px;min-width:0}
.form label,.modal-form label{
  color:var(--muted);
  font-size:14px;
  display:grid;
  gap:9px;
  min-width:0;
}
.form label small,.modal-form label small{line-height:1.5}
.form input,.form select,.modal-form input,.modal-form select,.modal-form textarea{
  appearance:none;
  width:100%;min-width:0;max-width:100%;display:block;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.09);
  color:var(--text);
  background:linear-gradient(180deg,rgba(255,255,255,.05),rgba(255,255,255,.03));
  padding:15px 16px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
  outline:none;
}
.form textarea,.modal-form textarea{resize:vertical;min-height:118px}
.form input::placeholder,.modal-form input::placeholder,.modal-form textarea::placeholder{color:#8e96ab}
.form input:focus,.form select:focus,.modal-form input:focus,.modal-form select:focus,.modal-form textarea:focus{
  border-color:rgba(173,159,255,.42);
  box-shadow:0 0 0 4px rgba(133,114,255,.12), inset 0 1px 0 rgba(255,255,255,.04);
}
.two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;min-width:0}
.two>*{min-width:0}
.check{
  display:flex!important;
  align-items:center;
  gap:12px;
  line-height:1.45;
}
.check input{
  width:22px!important;height:22px!important;flex:0 0 22px;
  border-radius:8px!important;
  accent-color:var(--purple-strong);
  padding:0!important;
}
dialog{
  position:fixed;
  inset:auto 8px calc(8px + env(safe-area-inset-bottom));
  margin:0 auto;
  width:min(720px, calc(100vw - 16px));
  max-width:calc(100vw - 16px);
  max-height:min(92dvh, 920px);
  overflow:hidden;
  padding:0;
  border-radius:34px;
  border:1px solid rgba(255,255,255,.08);
  color:var(--text);
  background:linear-gradient(180deg, rgba(15,19,31,.76), rgba(9,12,22,.72));
  box-shadow:0 28px 72px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter:blur(28px) saturate(165%);
  -webkit-backdrop-filter:blur(28px) saturate(165%);
  overscroll-behavior:contain;
}
dialog::backdrop{
  background:rgba(4,7,13,.5);
  backdrop-filter:blur(12px) saturate(130%);
  -webkit-backdrop-filter:blur(12px) saturate(130%);
}
.modal-form{
  width:100%;
  min-width:0;
  overflow:auto;
  max-height:min(92dvh, 920px);
  padding:16px 16px calc(22px + env(safe-area-inset-bottom));
  scrollbar-width:thin;
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  position:sticky;
  top:0;
  z-index:2;
  margin:-16px -16px 0;
  padding:18px 16px 12px;
  background:linear-gradient(180deg, rgba(16,21,35,.92) 0%, rgba(16,21,35,.78) 75%, rgba(16,21,35,0) 100%);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
}
.modal-head::before{
  content:"";
  position:absolute;
  left:50%;top:8px;transform:translateX(-50%);
  width:54px;height:5px;border-radius:999px;
  background:rgba(255,255,255,.15);
}
.modal-head h2{margin:18px 0 0;font-size:24px}
.close{
  flex:0 0 42px;
  width:42px;height:42px;
  border:1px solid rgba(255,255,255,.06);
  background:rgba(255,255,255,.05);
  border-radius:50%;
  color:#c9cfdd;
  font-size:30px;
  line-height:1;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04);
}
nav{
  position:fixed;
  left:50%;
  bottom:calc(10px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  z-index:30;
  width:min(720px, calc(100vw - 20px));
  max-width:calc(100vw - 20px);
  display:flex;
  justify-content:space-around;
  gap:4px;
  padding:10px 8px;
  border-radius:28px;
  background:linear-gradient(180deg, rgba(18,22,34,.72), rgba(14,18,31,.62));
  border:1px solid rgba(255,255,255,.09);
  box-shadow:0 18px 44px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter:blur(28px) saturate(170%);
  -webkit-backdrop-filter:blur(28px) saturate(170%);
}
nav button{
  flex:1;
  min-width:0;
  border:0;
  background:none;
  color:#7f879d;
  font-size:11px;
  font-weight:700;
  letter-spacing:.01em;
  display:grid;
  gap:5px;
  justify-items:center;
  align-content:center;
  padding:2px 6px;
}
nav .nav-icon{
  width:34px;height:34px;
  display:grid;place-items:center;
  border-radius:12px;
  color:inherit;
  transition:background .18s ease,color .18s ease,transform .18s ease,box-shadow .18s ease;
}
nav button .svg-icon{width:22px;height:22px}
nav button.selected{color:#d8d1ff}
nav button.selected .nav-icon{
  color:#cbbfff;
  background:linear-gradient(180deg, rgba(139,122,255,.22), rgba(118,99,241,.12));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.07);
  transform:translateY(-1px);
}
#toast{
  position:fixed;
  z-index:60;
  bottom:110px;
  left:50%;
  transform:translateX(-50%);
  max-width:min(90vw,520px);
  padding:12px 16px;
  border-radius:16px;
  background:rgba(27,33,51,.82);
  border:1px solid rgba(255,255,255,.09);
  box-shadow:0 16px 30px rgba(0,0,0,.28);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  display:none;
  text-align:center;
}
.done{text-decoration:line-through;opacity:.62}

@media (max-width:560px){
  .app{padding-left:8px;padding-right:8px}
  .grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  .tile{min-height:152px;padding:18px 16px}
  .tile b{font-size:20px}
}
@media (max-width:430px){
  header{padding:13px 14px;border-radius:24px;margin-left:2px;margin-right:2px}
  .logo{width:42px;height:42px;border-radius:15px}
  .pill{padding:8px 10px;font-size:10px}
  main{padding-left:2px;padding-right:2px}
  .hero,.card,.item{border-radius:26px}
  .hero{padding:22px 18px}
  .hero h2{font-size:26px}
  .grid{gap:10px}
  .tile{min-height:144px;border-radius:24px}
  .icon{width:44px;height:44px}
  .date-nav{grid-template-columns:42px minmax(0,1fr) 42px;gap:10px}
  .date-nav button{width:42px;height:42px;border-radius:16px}
  dialog{inset:auto 6px calc(6px + env(safe-area-inset-bottom));width:calc(100vw - 12px);max-width:calc(100vw - 12px);border-radius:30px}
  .modal-form{padding:14px 14px calc(20px + env(safe-area-inset-bottom))}
  .modal-head{margin:-14px -14px 0;padding:16px 14px 10px}
  .modal-head h2{font-size:22px}
  nav{width:calc(100vw - 16px);max-width:calc(100vw - 16px);bottom:calc(8px + env(safe-area-inset-bottom));border-radius:24px;padding:9px 6px}
}
@media (max-width:390px){
  h1{font-size:clamp(28px,9vw,36px)}
  .muted{margin-bottom:18px}
  .two{grid-template-columns:1fr}
  .deadline-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .tile{min-height:136px;padding:16px 14px}
  .tile b{font-size:18px}
  .tile small{font-size:14px}
  .item h3{font-size:20px}
  .form input,.form select,.modal-form input,.modal-form select,.modal-form textarea{padding:14px}
  nav button{font-size:10px}
  nav .nav-icon{width:32px;height:32px}
}

/* v5 form overflow fixes for Telegram iOS webview */
html,body,.app,main,.screen{min-width:0;max-width:100%;overflow-x:clip}
dialog .modal-form, dialog .modal-form>*{min-width:0;max-width:100%}
dialog .modal-form input,dialog .modal-form select,dialog .modal-form textarea{box-sizing:border-box;min-width:0;max-width:100%;font-size:16px}
dialog .modal-form input[type="date"],dialog .modal-form input[type="time"]{width:100%;min-width:0;max-width:100%;padding:12px 10px;min-height:52px;line-height:1.2}
dialog .two{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;max-width:100%}
@media(max-width:650px){dialog .two,dialog .deadline-row{grid-template-columns:minmax(0,1fr)}dialog .modal-form{max-height:calc(91dvh - env(safe-area-inset-bottom))}}
.form input,.form select{min-width:0}

/* Study Mini App v5.1: iOS sheet header and layout fix. */
/* Prevent sticky header from overlapping the first field while scrolling. */
dialog .modal-form { position:relative; display:grid; grid-auto-flow:row; gap:18px; padding-top:18px; overscroll-behavior:contain; }
dialog .modal-head {
  position:relative; top:auto; z-index:1;
  margin:0 0 4px; padding:16px 0 6px;
  width:100%; min-width:0;
  display:flex; flex-direction:row; align-items:center; justify-content:space-between;
  gap:14px; flex-wrap:nowrap;
  background:none; -webkit-backdrop-filter:none; backdrop-filter:none;
  border:0; box-shadow:none;
}
dialog .modal-head::before { display:none!important;content:none!important; }
dialog .modal-head h2 {
  margin:0!important; padding:0; min-width:0; flex:1 1 auto;
  font-size:clamp(22px,6vw,28px); line-height:1.16;
  letter-spacing:-.03em; font-weight:750; overflow-wrap:anywhere;
}
dialog .modal-head .close {
  position:static!important; inset:auto!important; margin:0!important;
  padding:0; flex:0 0 40px; width:40px; height:40px;
  display:grid;place-items:center; align-self:center;
  font-size:25px; line-height:1; font-weight:400;
  border-radius:50%; background:rgba(255,255,255,.09);
  border:1px solid rgba(255,255,255,.12);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.08);
  color:#dbe0ed; -webkit-tap-highlight-color:transparent;
}
dialog .modal-head .close:focus-visible{outline:2px solid #a998ff;outline-offset:3px}
dialog .modal-form>label:first-of-type { margin-top:0; }
dialog .modal-form input, dialog .modal-form select, dialog .modal-form textarea {max-width:100%;min-width:0}
dialog .modal-form .two {grid-template-columns:repeat(2,minmax(0,1fr))}
dialog .modal-form .two>*{min-width:0}
/* Narrow iPhones: stack field pairs to avoid oversized native date/time controls. */
@media(max-width:430px){
 dialog .modal-form {padding-top:16px}
 dialog .modal-head {padding-top:14px; padding-bottom:6px; gap:10px}
 dialog .modal-head h2 {font-size:24px}
 dialog .modal-head .close {flex-basis:38px;width:38px;height:38px;font-size:23px}
 dialog .modal-form .two {grid-template-columns:minmax(0,1fr)}
}
