  :root{
    --ink:#1E2530;
    --ink-soft:#5b6270;
    --parchment:#EFE7D3;
    --paper:#FBF7EC;
    --paper-dark:#242B37;
    --rail-dark:#171C24;
    --forest:#3E6259;
    --forest-deep:#2C4740;
    --brass:#C08A3E;
    --brick:#A03B2E;
    --line:rgba(30,37,48,0.16);
    --line-dark:rgba(255,255,255,0.12);
    font-family:'Padauk','Inter',sans-serif;
  }
  *{box-sizing:border-box; margin:0; padding:0;}
  html,body{height:100%;}
  body{
    background:var(--parchment) radial-gradient(rgba(30,37,48,0.05) 1px, transparent 1px) 0 0/3px 3px;
    color:var(--ink);
    font-size:15px;
    transition:background .2s ease,color .2s ease;
  }
  body.dark{
    background-color:var(--rail-dark);
    background-image:radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
    color:#EFE7D3;
  }
  a{color:inherit; text-decoration:none;}
  button{font:inherit; color:inherit; background:none; border:none; cursor:pointer;}
  input{font:inherit; color:inherit;}
  .display{font-family:'Fraunces',serif;}
  svg{display:block;}

  .app{display:flex; height:100vh; overflow:hidden;}

  /* ===== Rail (desktop only) ===== */
  .rail{
    display:none;
    width:230px; flex-shrink:0; flex-direction:column;
    border-right:1px solid var(--line);
    background:var(--paper);
    background-image:repeating-linear-gradient(to bottom, var(--line) 0 3px, transparent 3px 9px);
    background-position:right top; background-size:1px 100%; background-repeat:repeat-y;
  }
  body.dark .rail{background-color:var(--rail-dark); border-color:var(--line-dark);}
  .rail-head{padding:28px 24px 20px;}
  .brand{display:flex; align-items:center; gap:10px;}
  .brand-icon{width:32px;height:32px;border-radius:3px;background:var(--forest);display:flex;align-items:center;justify-content:center;flex-shrink:0;}
  .brand-icon svg{width:16px;height:16px;stroke:var(--paper);}
  .brand-title{font-size:18px; font-weight:600; line-height:1;}
  .brand-sub{font-size:11px; color:var(--ink-soft); margin-top:4px; line-height:1;}
  body.dark .brand-sub{color:#8b93a3;}

  .nav{flex:1; overflow-y:auto; padding-bottom:16px;}
  .spine{
    display:flex; align-items:center; justify-content:space-between;
    padding:10px 24px; font-size:14px;
    border-left:6px solid transparent;
    transition:background .15s ease;
  }
  .spine:hover{background:rgba(30,37,48,0.05);}
  body.dark .spine:hover{background:rgba(255,255,255,0.05);}
  .spine.active{border-left-color:var(--forest); background:rgba(62,98,89,0.1); font-weight:600;}
  body.dark .spine.active{border-left-color:var(--brass); background:rgba(192,138,62,0.14);}
  .spine-left{display:flex; align-items:center; gap:10px;}
  .spine-left svg{width:15px;height:15px;stroke:currentColor; flex-shrink:0;}
  .dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;}
  .spine-count{font-size:12px; color:var(--ink-soft);}
  body.dark .spine-count{color:#8b93a3;}
  .spine.locked{color:var(--brick);}

  .nav-label{padding:16px 24px 6px; font-size:10.5px; letter-spacing:.04em; text-transform:uppercase; color:var(--ink-soft);}
  body.dark .nav-label{color:#7a8496;}

  .rail-foot{padding:14px 24px; border-top:1px solid var(--line); display:flex; align-items:center; justify-content:space-between;}
  body.dark .rail-foot{border-color:var(--line-dark);}
  .rail-foot span{font-size:12px; color:var(--ink-soft);}
  body.dark .rail-foot span{color:#8b93a3;}
  .theme-btn{width:28px;height:28px;border:1px solid var(--line); border-radius:3px; display:flex; align-items:center; justify-content:center;}
  body.dark .theme-btn{border-color:var(--line-dark);}
  .theme-btn svg{width:14px;height:14px; stroke:currentColor;}

  /* ===== Main ===== */
  .main{flex:1; display:flex; flex-direction:column; overflow:hidden; min-width:0;}

  .topbar{border-bottom:1px solid var(--line); background:var(--parchment); padding:18px 20px 14px;}
  body.dark .topbar{background:var(--rail-dark); border-color:var(--line-dark);}

  .topbar-mobile{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;}
  .topbar-mobile .brand{gap:8px;}
  .topbar-mobile .brand-icon{width:28px;height:28px;}
  .topbar-mobile .brand-title{font-size:16px;}

  .search-row{display:flex; align-items:center; gap:10px;}
  .search-wrap{position:relative; flex:1;}
  .search-wrap svg{position:absolute; left:11px; top:50%; transform:translateY(-50%); width:15px;height:15px; stroke:var(--ink-soft);}
  .search-input{
    width:100%; background:var(--paper); border:1px solid var(--line); border-radius:3px;
    padding:10px 12px 10px 34px; font-size:14px; outline:none;
  }
  body.dark .search-input{background:var(--paper-dark); border-color:var(--line-dark); color:#EFE7D3;}
  .search-input:focus{border-color:var(--forest);}
  .search-input::placeholder{color:#8b8272;}
  body.dark .search-input::placeholder{color:#7a8496;}

  .add-btn{
    display:flex; align-items:center; gap:8px; white-space:nowrap;
    background:var(--forest); color:var(--paper); border-radius:3px; padding:10px 16px; font-size:14px; font-weight:600;
  }
  .add-btn:hover{background:var(--forest-deep);}
  .add-btn svg{width:15px;height:15px; stroke:currentColor;}

  .chip-row{display:flex; gap:8px; margin-top:14px; overflow-x:auto; padding-bottom:2px; -ms-overflow-style:none; scrollbar-width:none;}
  .chip-row::-webkit-scrollbar{display:none;}
  .chip{
    display:flex; align-items:center; gap:6px; white-space:nowrap;
    padding:7px 13px; border-radius:99px; font-size:12.5px; font-weight:500;
    border:1px solid var(--line); flex-shrink:0;
  }
  body.dark .chip{border-color:var(--line-dark);}
  .chip.active{background:var(--forest); color:var(--paper); border-color:var(--forest);}
  .chip.locked{color:var(--brick);}
  .chip svg{width:11px;height:11px; stroke:currentColor;}

  .content{flex:1; overflow-y:auto; padding:22px 20px 90px;}
  .content-head{display:flex; align-items:baseline; justify-content:space-between; margin-bottom:18px;}
  .content-head h2{font-size:21px; font-weight:600;}
  .content-head span{font-size:12px; color:var(--ink-soft);}
  body.dark .content-head span{color:#8b93a3;}

  .grid{display:grid; grid-template-columns:1fr; gap:14px;}

  .card{
    background:var(--paper); border:1px solid var(--line); border-radius:3px; padding:16px;
    position:relative; overflow:hidden;
  }
  body.dark .card{background:var(--paper-dark); border-color:var(--line-dark);}

  .fold::before{
    content:''; position:absolute; top:0; right:0;
    border-style:solid; border-width:0 24px 24px 0;
    border-color:transparent var(--brass) transparent transparent;
  }

  .card-head{display:flex; align-items:flex-start; gap:11px; margin-bottom:10px;}
  .avatar{
    width:34px;height:34px; border-radius:3px; flex-shrink:0;
    display:flex; align-items:center; justify-content:center;
    color:var(--paper); font-size:12px; font-weight:700;
  }
  .card-title{font-size:14px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .card-domain{font-size:11.5px; color:var(--ink-soft); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:2px;}
  body.dark .card-domain{color:#8b93a3;}
  .card-desc{
    font-size:12.5px; line-height:1.55; color:var(--ink-soft); margin-bottom:12px;
    display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  }
  body.dark .card-desc{color:#a6adba;}

  .card-foot{display:flex; align-items:center; justify-content:space-between; padding-top:10px; border-top:1px dashed var(--line);}
  body.dark .card-foot{border-color:var(--line-dark);}
  .card-date{font-size:11px; color:#8b8272;}
  body.dark .card-date{color:#6f7889;}
  .card-actions{display:flex; gap:2px;}
  .icon-btn{width:26px;height:26px; border-radius:3px; display:flex; align-items:center; justify-content:center;}
  .icon-btn:hover{background:rgba(30,37,48,0.06);}
  body.dark .icon-btn:hover{background:rgba(255,255,255,0.08);}
  .icon-btn svg{width:14px;height:14px; stroke:currentColor;}

  .locked-body{filter:blur(3px); user-select:none;}
  .locked-overlay{
    position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
    background:rgba(251,247,236,0.55);
  }
  body.dark .locked-overlay{background:rgba(36,43,55,0.6);}
  .locked-badge{
    display:flex; align-items:center; gap:6px; font-size:12px; font-weight:600;
    background:var(--paper); border:1px solid var(--line); padding:7px 13px; border-radius:99px;
  }
  body.dark .locked-badge{background:var(--paper-dark); border-color:var(--line-dark);}
  .locked-badge svg{width:12px;height:12px; stroke:currentColor;}

  .fab{
    display:flex; position:fixed; bottom:20px; right:20px; width:54px;height:54px; border-radius:50%;
    background:var(--forest); color:var(--paper); align-items:center; justify-content:center;
    box-shadow:0 8px 20px rgba(30,37,48,0.3); z-index:20;
  }
  .fab svg{width:24px;height:24px; stroke:currentColor;}

  /* ===== Breakpoints ===== */
  @media (min-width:768px){
    .rail{display:flex;}
    .topbar-mobile, .chip-row, .fab{display:none;}
    .topbar{padding:22px 32px 18px;}
    .content{padding:26px 32px;}
    .grid{grid-template-columns:repeat(2, 1fr);}
    .add-btn{display:flex;}
  }
  @media (min-width:1180px){
    .grid{grid-template-columns:repeat(3, 1fr);}
  }
  @media (max-width:767px){
    .add-btn{display:none;}
  }

  /* ===== Type badge (Link / Note) ===== */
  .type-badge{
    display:inline-flex; align-items:center; gap:4px;
    font-size:10.5px; font-weight:600; letter-spacing:.02em;
    padding:2px 8px; border-radius:99px; flex-shrink:0;
  }
  .type-badge svg{width:10px;height:10px; stroke:currentColor;}
  .type-badge.link{ background:rgba(62,98,89,0.12); color:var(--forest-deep); }
  .dark .type-badge.link{ background:rgba(62,98,89,0.25); color:#8fb8a8; }
  .type-badge.note{ background:rgba(192,138,62,0.14); color:#8a611f; }
  .dark .type-badge.note{ background:rgba(192,138,62,0.22); color:var(--brass); }

  .note-avatar{ background:var(--brass) !important; }
  .note-avatar svg{ width:16px;height:16px; stroke:var(--paper); }

  .card.note-card .card-desc{ -webkit-line-clamp:4; }

  /* ===== Modal ===== */
  .modal-backdrop{
    display:none; position:fixed; inset:0; z-index:50;
    background:rgba(23,28,36,0.55);
    align-items:center; justify-content:center; padding:16px;
  }
  .modal-backdrop.open{display:flex;}
  .modal{
    width:100%; max-width:460px; max-height:88vh; overflow-y:auto;
    background:var(--paper); border:1px solid var(--line); border-radius:4px;
  }
  body.dark .modal{background:var(--paper-dark); border-color:var(--line-dark);}
  .modal-head{display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--line);}
  body.dark .modal-head{border-color:var(--line-dark);}
  .modal-head h3{font-size:16px; font-weight:600;}
  .modal-close{width:28px;height:28px; border-radius:3px; display:flex; align-items:center; justify-content:center;}
  .modal-close:hover{background:rgba(30,37,48,0.06);}
  body.dark .modal-close:hover{background:rgba(255,255,255,0.08);}
  .modal-close svg{width:16px;height:16px; stroke:currentColor;}
  .modal-body{padding:20px;}

  .segmented{display:flex; border:1px solid var(--line); border-radius:3px; overflow:hidden; margin-bottom:18px;}
  body.dark .segmented{border-color:var(--line-dark);}
  .segmented button{flex:1; padding:9px; font-size:13px; font-weight:600; display:flex; align-items:center; justify-content:center; gap:6px;}
  .segmented button svg{width:14px;height:14px; stroke:currentColor;}
  .segmented button.active{background:var(--forest); color:var(--paper);}
  .segmented button:not(.active):hover{background:rgba(30,37,48,0.05);}
  body.dark .segmented button:not(.active):hover{background:rgba(255,255,255,0.05);}

  .form-field{margin-bottom:14px;}
  .form-field label{display:block; font-size:12px; font-weight:600; margin-bottom:5px;}
  .form-field input[type="text"], .form-field input[type="url"], .form-field textarea, .form-field select{
    width:100%; background:var(--parchment); border:1px solid var(--line); border-radius:3px;
    padding:9px 11px; font-size:13.5px; outline:none; font-family:inherit;
  }
  body.dark .form-field input, body.dark .form-field textarea, body.dark .form-field select{
    background:var(--rail-dark); border-color:var(--line-dark); color:#EFE7D3;
  }
  .form-field input:focus, .form-field textarea:focus, .form-field select:focus{border-color:var(--forest);}
  .form-field textarea{resize:vertical; min-height:64px; font-family:inherit;}
  .form-hint{font-size:11px; color:var(--ink-soft); margin-top:4px;}
  body.dark .form-hint{color:#8b93a3;}

  .toggle-row{display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-top:1px dashed var(--line);}
  body.dark .toggle-row{border-color:var(--line-dark);}
  .toggle-row span{font-size:13px; font-weight:500; display:flex; align-items:center; gap:7px;}
  .toggle-row span svg{width:14px;height:14px; stroke:currentColor;}
  .switch{position:relative; width:38px;height:21px; flex-shrink:0;}
  .switch input{opacity:0; width:0;height:0; position:absolute;}
  .switch .track{position:absolute; inset:0; background:var(--line); border-radius:99px; transition:.15s; cursor:pointer;}
  .switch .track::before{content:''; position:absolute; width:15px;height:15px; left:3px; top:3px; background:var(--paper); border-radius:50%; transition:.15s;}
  .switch input:checked + .track{background:var(--forest);}
  .switch input:checked + .track::before{transform:translateX(17px);}

  .color-grid{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:14px;}
  .color-swatch{width:26px;height:26px; border-radius:50%; border:2px solid transparent; cursor:pointer;}
  .color-swatch.selected{border-color:var(--ink);}
  body.dark .color-swatch.selected{border-color:#EFE7D3;}

  .modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:18px;}
  .btn-ghost{padding:9px 16px; font-size:13.5px; font-weight:600; border:1px solid var(--line); border-radius:3px;}
  body.dark .btn-ghost{border-color:var(--line-dark);}
  .btn-primary{padding:9px 16px; font-size:13.5px; font-weight:600; background:var(--forest); color:var(--paper); border-radius:3px;}
  .btn-primary:hover{background:var(--forest-deep);}

  /* Category manage list */
  .cat-row{display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--line);}
  body.dark .cat-row{border-color:var(--line-dark);}
  .cat-row:last-child{border-bottom:none;}
  .cat-row .dot{width:12px;height:12px;}
  .cat-row .cat-name{flex:1; font-size:13.5px; font-weight:500;}
  .cat-row .cat-count{font-size:11.5px; color:var(--ink-soft);}
  body.dark .cat-row .cat-count{color:#8b93a3;}
  .cat-row-actions{display:flex; gap:2px;}

/* ===== Auth (Login) Page ===== */
.auth-wrap{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  padding:24px;
}
.auth-card{
  width:100%; max-width:360px;
  background:var(--paper); border:1px solid var(--line); border-radius:4px;
  padding:32px 28px;
}
body.dark .auth-card{background:var(--paper-dark); border-color:var(--line-dark);}
.auth-brand{display:flex; flex-direction:column; align-items:center; text-align:center; margin-bottom:24px;}
.auth-brand .brand-icon{width:44px;height:44px; margin-bottom:12px;}
.auth-brand .brand-icon svg{width:22px;height:22px;}
.auth-brand h1{font-size:20px; font-weight:600;}
.auth-brand p{font-size:12px; color:var(--ink-soft); margin-top:4px;}
body.dark .auth-brand p{color:#8b93a3;}

.field{margin-bottom:16px;}
.field label{display:block; font-size:12.5px; font-weight:600; margin-bottom:6px;}
.field input{
  width:100%; background:var(--parchment); border:1px solid var(--line); border-radius:3px;
  padding:11px 12px; font-size:14px; outline:none;
}
body.dark .field input{background:var(--rail-dark); border-color:var(--line-dark); color:#EFE7D3;}
.field input:focus{border-color:var(--forest);}

.auth-submit{
  width:100%; background:var(--forest); color:var(--paper); border-radius:3px;
  padding:12px; font-size:14px; font-weight:600; margin-top:4px;
}
.auth-submit:hover{background:var(--forest-deep);}
.auth-submit:disabled{opacity:.6; cursor:not-allowed;}

.auth-error{
  background:rgba(160,59,46,0.1); border:1px solid rgba(160,59,46,0.35); color:var(--brick);
  font-size:12.5px; padding:10px 12px; border-radius:3px; margin-bottom:16px;
}
.auth-note{font-size:11px; color:var(--ink-soft); text-align:center; margin-top:18px; line-height:1.6;}
body.dark .auth-note{color:#7a8496;}
.grecaptcha-badge{ z-index:30; }

/* ===== Dashboard topbar user area ===== */
.user-pill{display:flex; align-items:center; gap:10px;}
.user-pill span{font-size:12px; color:var(--ink-soft);}
body.dark .user-pill span{color:#8b93a3;}
.logout-link{font-size:12px; color:var(--brick); font-weight:600;}
.logout-link:hover{text-decoration:underline;}

.notice-banner{
  display:flex; align-items:center; gap:10px; background:rgba(62,98,89,0.1);
  border:1px solid rgba(62,98,89,0.3); color:var(--forest-deep);
  font-size:12.5px; padding:10px 14px; border-radius:3px; margin-bottom:18px;
}
body.dark .notice-banner{background:rgba(192,138,62,0.12); border-color:rgba(192,138,62,0.35); color:var(--brass);}
.notice-banner.error{background:rgba(160,59,46,0.1); border-color:rgba(160,59,46,0.35); color:var(--brick);}
.notice-banner svg{flex-shrink:0;}

/* ===== Empty state ===== */
.empty-state{
  text-align:center; padding:60px 20px; color:var(--ink-soft);
}
body.dark .empty-state{color:#8b93a3;}
.empty-state svg{width:36px;height:36px; margin:0 auto 12px; opacity:.5;}
.empty-state p{font-size:13.5px;}

/* ===== Locked card unlock form ===== */
.unlock-form{
  display:flex; align-items:center; gap:6px; background:var(--paper); border:1px solid var(--line);
  padding:6px; border-radius:99px;
}
body.dark .unlock-form{background:var(--paper-dark); border-color:var(--line-dark);}
.unlock-form input{
  border:none; background:transparent; font-size:12px; padding:4px 8px; outline:none; width:110px; color:inherit;
}
.unlock-form button{
  background:var(--forest); color:var(--paper); font-size:11.5px; font-weight:600;
  padding:6px 12px; border-radius:99px; white-space:nowrap;
}
.unlock-form button:hover{background:var(--forest-deep);}

.card-link{cursor:pointer;}
.category-tag{
  display:inline-flex; align-items:center; gap:5px; font-size:11.5px; color:var(--ink-soft);
}
body.dark .category-tag{color:#8b93a3;}

/* ===== View modal content ===== */
.view-content{
  white-space:pre-wrap; word-wrap:break-word;
  font-size:13.5px; line-height:1.75; font-family:'Padauk','Inter',sans-serif;
}

/* ===== Sort select ===== */
.sort-select{
  background:var(--paper); border:1px solid var(--line); border-radius:3px;
  padding:0 8px; font-size:12.5px; color:inherit; outline:none; flex-shrink:0;
}
body.dark .sort-select{background:var(--paper-dark); border-color:var(--line-dark); color:#EFE7D3;}

/* ===== Tag pills ===== */
.tag-pills{display:flex; flex-wrap:wrap; gap:5px; margin:8px 0;}
.tag-pill{
  font-size:10.5px; color:var(--forest-deep); background:rgba(62,98,89,0.08);
  padding:2px 8px; border-radius:99px; white-space:nowrap;
}
body.dark .tag-pill{color:#8fb8a8; background:rgba(62,98,89,0.2);}
.tag-pill:hover{background:rgba(62,98,89,0.16);}
body.dark .tag-pill:hover{background:rgba(62,98,89,0.3);}

/* ===== Auto-fetch button ===== */
.url-row{display:flex; gap:8px;}
.url-row input{flex:1;}
.fetch-btn{
  flex-shrink:0; display:flex; align-items:center; gap:5px; padding:0 12px;
  background:rgba(62,98,89,0.1); color:var(--forest-deep); border-radius:3px; font-size:12.5px; font-weight:600;
  white-space:nowrap;
}
body.dark .fetch-btn{background:rgba(192,138,62,0.15); color:var(--brass);}
.fetch-btn:hover{background:rgba(62,98,89,0.18);}
.fetch-btn svg{width:13px;height:13px;}
.fetch-btn[disabled]{opacity:.6; cursor:wait;}

/* ===== Dashboard widgets ===== */
.widget-grid{display:grid; grid-template-columns:1fr; gap:14px;}
.widget{background:var(--paper); border:1px solid var(--line); border-radius:4px; padding:18px; position:relative; overflow:hidden;}
body.dark .widget{background:var(--paper-dark); border-color:var(--line-dark);}
.widget-title{display:flex; align-items:center; gap:8px; font-size:12px; font-weight:700; letter-spacing:.03em; text-transform:uppercase; color:var(--ink-soft); margin-bottom:14px;}
body.dark .widget-title{color:#8b93a3;}
.widget-title svg{width:14px;height:14px; stroke:currentColor;}

.clock-time{font-family:'Fraunces',serif; font-size:44px; font-weight:600; line-height:1;}
.clock-date{font-size:12.5px; color:var(--ink-soft); margin-top:8px;} body.dark .clock-date{color:#8b93a3;}
.clock-greet{font-size:12.5px; color:var(--forest-deep); margin-top:4px; font-weight:600;}
body.dark .clock-greet{color:var(--brass);}

.market-row{display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px dashed var(--line);}
body.dark .market-row{border-color:var(--line-dark);}
.market-row:last-child{border-bottom:none;}
.market-name{display:flex; align-items:center; gap:10px; font-size:13.5px; font-weight:600;}
.market-icon{width:28px;height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; color:var(--paper); flex-shrink:0;}
.market-price{text-align:right;}
.market-price .amt{font-size:14px; font-weight:700;}
.market-change{font-size:11px; display:flex; align-items:center; gap:2px; justify-content:flex-end; margin-top:2px;}
.market-change.up{color:var(--forest-deep);} body.dark .market-change.up{color:#8fb8a8;}
.market-change.down{color:var(--brick);}
.market-change svg{width:10px;height:10px;}
.market-note{font-size:10.5px; color:var(--ink-soft); margin-top:12px;} body.dark .market-note{color:#7a8496;}

.todo-item{display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line);}
body.dark .todo-item{border-color:var(--line-dark);}
.todo-item:last-of-type{border-bottom:none;}
.todo-check{width:18px;height:18px; border:1.5px solid var(--line); border-radius:4px; flex-shrink:0; display:flex; align-items:center; justify-content:center; cursor:pointer; background:none;}
body.dark .todo-check{border-color:var(--line-dark);}
.todo-item.done .todo-check{background:var(--forest); border-color:var(--forest);}
.todo-check svg{width:11px;height:11px; stroke:var(--paper); display:none;}
.todo-item.done .todo-check svg{display:block;}
.todo-text{font-size:13.5px; flex:1; text-align:left; background:none; border:none;}
.todo-item.done .todo-text{color:var(--ink-soft); text-decoration:line-through;}
body.dark .todo-item.done .todo-text{color:#7a8496;}
.todo-del{opacity:0; font-size:11px; color:var(--brick); flex-shrink:0;}
.todo-item:hover .todo-del{opacity:1;}
.todo-add{display:flex; gap:8px; margin-top:12px;}
.todo-add input{flex:1; background:var(--parchment); border:1px solid var(--line); border-radius:3px; padding:8px 10px; font-size:13px; outline:none;}
body.dark .todo-add input{background:var(--rail-dark); border-color:var(--line-dark); color:#EFE7D3;}
.todo-add button{background:var(--forest); color:var(--paper); border-radius:3px; padding:0 14px; font-size:13px; font-weight:600;}

.sticky-grid{display:grid; grid-template-columns:repeat(2, 1fr); gap:12px;}
.sticky{padding:14px 12px 30px; font-size:12.5px; line-height:1.6; color:#2b2718; min-height:96px; box-shadow:0 3px 8px rgba(0,0,0,0.12); position:relative; transform:rotate(var(--tilt, -1.2deg)); font-family:'Padauk','Inter',sans-serif; border:none; text-align:left; display:block; width:100%;}
.sticky::before{content:''; position:absolute; top:-6px; left:50%; transform:translateX(-50%) rotate(-3deg); width:34px; height:14px; background:rgba(255,255,255,0.55); border:1px solid rgba(0,0,0,0.05);}
.sticky.c1{background:#F3D98B; --tilt:-1.4deg;} .sticky.c2{background:#C9DCC6; --tilt:1.1deg;}
.sticky.c3{background:#EFC2BC; --tilt:-0.8deg;} .sticky.c4{background:#C7D3DE; --tilt:1.6deg;}
.sticky-del{position:absolute; bottom:8px; right:10px; font-size:10.5px; color:rgba(43,39,24,0.5); font-weight:600; background:none; border:none;}
.sticky-add{display:flex; align-items:center; justify-content:center; border:1.5px dashed var(--line); border-radius:2px; min-height:96px; color:var(--ink-soft); font-size:12px; font-weight:600; gap:6px; cursor:pointer; background:none; width:100%;}
body.dark .sticky-add{border-color:var(--line-dark); color:#8b93a3;}
.sticky-add svg{width:15px;height:15px;}
.sticky-form{display:flex; flex-direction:column; gap:8px; margin-top:12px;}
.sticky-form textarea{background:var(--parchment); border:1px solid var(--line); border-radius:3px; padding:8px 10px; font-size:12.5px; min-height:56px; outline:none;}
body.dark .sticky-form textarea{background:var(--rail-dark); border-color:var(--line-dark); color:#EFE7D3;}
.sticky-colors{display:flex; gap:6px;}
.sticky-color-opt{width:22px;height:22px; border-radius:50%; border:2px solid transparent; cursor:pointer;}
.sticky-color-opt.selected{border-color:var(--ink);} body.dark .sticky-color-opt.selected{border-color:#EFE7D3;}

.lib-row{display:flex; align-items:center; gap:11px; padding:9px 0; border-bottom:1px solid var(--line);}
body.dark .lib-row{border-color:var(--line-dark);}
.lib-row:last-of-type{border-bottom:none;}
.lib-avatar{width:26px;height:26px; border-radius:3px; display:flex; align-items:center; justify-content:center; color:var(--paper); font-size:10px; font-weight:700; flex-shrink:0;}
.lib-title{font-size:12.5px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.view-all{display:block; text-align:center; margin-top:12px; font-size:12px; font-weight:600; color:var(--forest-deep); padding:8px; border-radius:3px; background:rgba(62,98,89,0.08);}
body.dark .view-all{color:var(--brass); background:rgba(192,138,62,0.12);}

@media (min-width:768px){
  .widget-grid{grid-template-columns:repeat(3, 1fr);}
}

/* ===== Feed page ===== */
.feed-list{display:flex; flex-direction:column; gap:10px; max-width:680px;}
.feed-item{background:var(--paper); border:1px solid var(--line); border-radius:4px; padding:14px 16px; display:flex; gap:12px; position:relative;}
body.dark .feed-item{background:var(--paper-dark); border-color:var(--line-dark);}
.feed-item.unread{border-left:3px solid var(--forest);} body.dark .feed-item.unread{border-left-color:var(--brass);}
.feed-avatar{width:38px;height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:var(--paper); font-size:13px; font-weight:700; flex-shrink:0;}
.feed-avatar svg{width:17px;height:17px; stroke:var(--paper);}
.feed-body{flex:1; min-width:0;}
.feed-meta{display:flex; align-items:center; gap:7px; font-size:12px; color:var(--ink-soft); margin-bottom:4px; flex-wrap:wrap;}
body.dark .feed-meta{color:#8b93a3;}
.feed-source{font-weight:700; color:var(--ink);} body.dark .feed-source{color:#EFE7D3;}
.platform-tag{font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.03em; padding:1px 7px; border-radius:99px; background:rgba(62,98,89,0.1); color:var(--forest-deep);}
body.dark .platform-tag{background:rgba(192,138,62,0.16); color:var(--brass);}
.feed-title{font-size:13.5px; font-weight:600; margin-bottom:4px; line-height:1.4; display:block;}
.feed-snippet{font-size:12.5px; color:var(--ink-soft); line-height:1.6; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;}
body.dark .feed-snippet{color:#a6adba;}
.feed-thumb{width:64px;height:64px; border-radius:4px; flex-shrink:0; background:var(--parchment); border:1px solid var(--line); overflow:hidden;}
body.dark .feed-thumb{background:var(--rail-dark); border-color:var(--line-dark);}
.feed-thumb img{width:100%;height:100%;object-fit:cover;}
.feed-foot{display:flex; align-items:center; justify-content:space-between; margin-top:8px;}
.feed-open{font-size:11.5px; font-weight:600; color:var(--forest-deep); display:flex; align-items:center; gap:4px;}
body.dark .feed-open{color:#8fb8a8;}
.feed-open svg{width:11px;height:11px;}
.unread-dot{width:7px;height:7px; border-radius:50%; background:var(--forest); position:absolute; top:14px; right:14px;}
body.dark .unread-dot{background:var(--brass);}

.platform-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:14px;}
.platform-opt{display:flex; flex-direction:column; align-items:center; gap:6px; padding:12px 6px; border:1px solid var(--line); border-radius:4px; font-size:11px; font-weight:600; cursor:pointer; background:none;}
body.dark .platform-opt{border-color:var(--line-dark);}
.platform-opt.selected{border-color:var(--forest); background:rgba(62,98,89,0.08); color:var(--forest-deep);}
body.dark .platform-opt.selected{border-color:var(--brass); background:rgba(192,138,62,0.14); color:var(--brass);}
.platform-opt svg{width:18px;height:18px;}

.src-row{display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line);}
body.dark .src-row{border-color:var(--line-dark);}
.src-row:last-of-type{border-bottom:none;}
.src-name{flex:1; font-size:13px; font-weight:500;}
.src-count{font-size:11px; color:var(--ink-soft);} body.dark .src-count{color:#8b93a3;}
.src-error{font-size:10.5px; color:var(--brick); margin-top:1px;}

.refresh-btn{display:flex; align-items:center; gap:6px; font-size:12.5px; font-weight:600; color:var(--forest-deep); padding:7px 13px; border:1px solid var(--line); border-radius:99px;}
body.dark .refresh-btn{color:var(--brass); border-color:var(--line-dark);}
.refresh-btn svg{width:13px;height:13px;}
.refresh-btn.spinning svg{animation:spin 0.8s linear infinite;}
@keyframes spin{ to{ transform:rotate(360deg); } }

/* ===== Mobile nav drawer ===== */
.hamburger-btn{width:32px;height:32px; border:1px solid var(--line); border-radius:3px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
body.dark .hamburger-btn{border-color:var(--line-dark);}
.hamburger-btn svg{width:16px;height:16px; stroke:currentColor;}

.mobile-nav-backdrop{display:none; position:fixed; inset:0; background:rgba(23,28,36,0.5); z-index:59;}
.mobile-nav-backdrop.open{display:block;}

@media (max-width:767px){
  .rail.mobile-open{
    display:flex !important;
    position:fixed; top:0; left:0; bottom:0; width:250px; z-index:60;
    box-shadow:0 10px 40px rgba(0,0,0,0.35);
    animation: stacksSlideIn .18s ease;
  }
  .rail-close{display:flex; width:26px;height:26px; border-radius:3px; align-items:center; justify-content:center; position:absolute; top:24px; right:16px;}
  .rail-close svg{width:15px;height:15px; stroke:currentColor;}
}
@media (min-width:768px){
  .rail-close{display:none;}
}
@keyframes stacksSlideIn{ from{ transform:translateX(-100%); } to{ transform:translateX(0); } }

@media (max-width:767px){
  .desktop-only-gear{display:none;}
}
@media (min-width:768px){
  .desktop-only-gear{display:flex; justify-content:flex-end; margin-bottom:10px;}
}

/* ===== Photo Gallery ===== */
.gallery-grid{display:grid; grid-template-columns:repeat(2, 1fr); gap:10px;}
@media (min-width:600px){ .gallery-grid{grid-template-columns:repeat(3, 1fr);} }
@media (min-width:900px){ .gallery-grid{grid-template-columns:repeat(4, 1fr);} }
.gallery-tile{
  position:relative; aspect-ratio:1/1; border-radius:4px; overflow:hidden; border:1px solid var(--line);
  background:var(--paper); cursor:pointer;
}
body.dark .gallery-tile{background:var(--paper-dark); border-color:var(--line-dark);}
.gallery-tile img{width:100%; height:100%; object-fit:cover; display:block;}
.gallery-tile .gallery-actions{
  position:absolute; top:6px; right:6px; display:flex; gap:6px;
  opacity:0; transition:opacity .15s;
}
.gallery-tile:hover .gallery-actions{opacity:1;}
.gallery-view, .gallery-del{
  width:26px;height:26px; border-radius:50%;
  background:rgba(23,28,36,0.55); display:flex; align-items:center; justify-content:center;
}
.gallery-view svg, .gallery-del svg{width:13px;height:13px; stroke:#fff;}
.gallery-caption{
  position:absolute; left:0; right:0; bottom:0; padding:6px 8px; font-size:11px; color:#fff;
  background:linear-gradient(transparent, rgba(0,0,0,0.6)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

.lightbox-backdrop{display:none; position:fixed; inset:0; z-index:70; background:rgba(10,12,16,0.9); align-items:center; justify-content:center; padding:24px;}
.lightbox-backdrop.open{display:flex;}
.lightbox-backdrop img{max-width:100%; max-height:85vh; border-radius:4px;}
.lightbox-close{position:absolute; top:18px; right:20px; width:36px;height:36px; border-radius:50%; background:rgba(255,255,255,0.12); display:flex; align-items:center; justify-content:center;}
.lightbox-close svg{width:18px;height:18px; stroke:#fff;}
.lightbox-caption{position:absolute; bottom:20px; left:0; right:0; text-align:center; color:#fff; font-size:13px;}
