:root{
  --bg:#ffffff;
  --bg-gray:#f8f8f8;
  --bg-active:#f0f0f3;
  --bg-alt:#fff0c0; --muted:#6b7280; --accent:#111827; --radius:8px; --gap:12px;
  --bg-events:var(--bg-active);
}
*{box-sizing:border-box}
body{font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial; margin:0; background:var(--bg); color:#0f172a}

.app{max-width:640px;margin:0 auto;padding:12px}
.app-header{
  display:flex;align-items:center;justify-content:space-between;
  gap:8px;margin-bottom:12px;
}
.app-title{margin:0;font-size:1.3rem;color:var(--accent)}
.btn-today{
  background:var(--bg-gray);border:0;padding:8px 14px;border-radius:8px;cursor:pointer;
  font-size:13px;min-height:32px;flex:0 0 auto;color:#0f172a;
}
.btn-today:active{background:var(--bg-active)}

.source-toggles{
  display:flex;flex-wrap:nowrap;gap:6px;margin-bottom:12px;
  overflow-x:auto;-webkit-overflow-scrolling:touch;
  scrollbar-width:thin;padding-bottom:4px;
  -webkit-mask-image:linear-gradient(to right, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
  mask-image:linear-gradient(to right, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
}
.source-toggle{
  display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;
  background:var(--bg-gray);border:0;border-radius:16px;
  padding:6px 12px;cursor:pointer;font-size:13px;color:#0f172a;
  min-height:32px;transition:opacity .15s ease;
}
.source-toggle-dot{width:9px;height:9px;border-radius:50%;flex:0 0 auto}
.source-toggle-off{opacity:.4}
.source-toggle-off .source-toggle-label{text-decoration:line-through}

.page-intro{color:var(--muted);font-size:13px;margin:0 0 16px}
.back-link{display:inline-block;color:var(--muted);font-size:13px;text-decoration:none;margin-bottom:12px}
.back-link:hover{color:var(--accent)}

.card{background:var(--bg-gray);border-radius:var(--radius);padding:16px;margin-bottom:20px}
.card h2{font-size:15px;margin:0 0 14px;color:var(--accent)}

.form-group{margin-bottom:14px}
.form-group:last-of-type{margin-bottom:0}
.form-group label{display:block;font-size:13px;color:var(--muted);margin-bottom:5px}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"]{
  width:100%;padding:10px 12px;border:1px solid #e5e7eb;border-radius:8px;
  font-size:14px;background:var(--bg);color:#0f172a;
}
.form-group input:focus{outline:1px solid var(--muted);outline-offset:1px}
.form-group input[type="color"]{
  width:30px;height:30px;padding:0px;border:1px solid #fff;border-radius:50%;
  background:var(--bg);cursor:pointer;vertical-align:middle;
}
.form-actions{margin-top:18px}
.btn-primary{
  background:var(--accent);color:#fff;border:0;padding:10px 20px;border-radius:8px;
  font-size:14px;cursor:pointer;min-height:40px;
}
.btn-primary:active{opacity:.85}

.source-list{list-style:none;margin:0;padding:0}
.source-list li{
  display:flex;align-items:center;gap:10px;
  padding:10px 0;border-bottom:1px solid #eef0f2;
}
.source-list li:last-child{border-bottom:0}
.source-list-dot{width:10px;height:10px;border-radius:50%;flex:0 0 auto}
.source-list-info{min-width:0}
.source-list-name{font-weight:600;font-size:14px}
.source-list-url{font-size:12px;color:var(--muted);word-break:break-all}
.source-list-empty{color:var(--muted);font-size:13px}

.months{display:block}
/*.month{width:100%;background:#fff;border-radius:8px;padding:8px;box-shadow:0 1px 2px rgba(0,0,0,0.04)}*/
.month{width:100%;background:var(--bg);padding:6px;}
.month-title{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  font-weight:600;margin-bottom:8px;font-size:15px;
}
.month-title-label{flex:1;text-align:center}
.month-nav-btn{
  background:var(--bg-gray);border:0;border-radius:8px;
  width:30px;height:30px;font-size:16px;line-height:1;color:var(--accent);
  cursor:pointer;flex:0 0 auto;
}
.month-nav-btn:active{background:var(--bg-active)}

.month-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;overflow:hidden}
.cell{min-height:52px;padding:3px;border-radius:5px}
.cell-weekday{font-size:12px;color:var(--muted);text-align:center;padding:4px 0;min-height:24px;border-bottom:none}
.cell-day{background:var(--bg-gray);display:flex;flex-direction:column;cursor:pointer}
.cell-day:active{background:var(--bg-active)}
.cell-selected{outline:1px solid var(--muted);outline-offset:-2px}
.day-with-events{background:var(--bg-events)}
.day-num{font-size:12px;color:var(--muted);text-align:right;padding:3px 5px 2px}

.day-events{display:flex;flex-direction:column;gap:2px;margin-top:auto}
.day-alldot-bar{display:flex;height:3px;border-radius:3px;overflow:hidden}
.day-alldot-segment{flex:1;min-width:2px}
.event-lane{position:relative;height:3px}
.event-bar{
  position:absolute;top:0;bottom:0;
  min-width:6%;
  overflow:hidden;
}
.event-bar.bar-start{border-top-left-radius:3px;border-bottom-left-radius:3px}
.event-bar.bar-end{border-top-right-radius:3px;border-bottom-right-radius:3px}
.event-more{font-size:9px;color:var(--muted);text-align:right;padding-right:3px;line-height:1.4}

.cell-today{background-color:var(--bg-alt)}
.cell-today .day-num{font-weight:700;color:var(--muted)}

.events-list{margin-top:16px}
.events-list h2{font-size:15px;margin:0 0 8px}
.event-row{display:flex;align-items:flex-start;padding:10px 0;border-bottom:1px solid #f3f4f6}
.event-color{width:3px;align-self:stretch;border-radius:4px;margin-right:10px;flex:0 0 auto}
.event-info{min-width:0}
.event-title{font-weight:600;font-size:14px;word-break:break-word}
.event-meta{font-size:12px;color:var(--muted);word-break:break-word}

.modal-backdrop{
  position:fixed;inset:0;background:rgba(15,23,42,.45);
  display:flex;align-items:flex-end;justify-content:center;
  z-index:1000;opacity:0;pointer-events:none;transition:opacity .15s ease;
}
.modal-backdrop.open{opacity:1;pointer-events:auto}
.modal-panel{
  background:var(--bg);width:100%;max-width:480px;
  border-radius:16px 16px 0 0;padding:16px;max-height:75vh;overflow-y:auto;
  transform:translateY(100%);transition:transform .2s ease;
}
.modal-backdrop.open .modal-panel{transform:translateY(0)}
.modal-header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}
.modal-title{font-size:15px;font-weight:600;color:var(--accent);margin:0}
.modal-close{
  background:var(--bg-gray);border:0;border-radius:50%;width:28px;height:28px;
  font-size:13px;color:var(--muted);cursor:pointer;flex:0 0 auto;
}
.modal-close:active{background:var(--bg-active)}
.modal-body .event-row:first-child{padding-top:0}

.events-loading{display:flex;align-items:center;justify-content:center;gap:8px;padding:24px 0;color:var(--muted);font-size:13px}
.spinner{width:15px;height:15px;border:2px solid #e5e7eb;border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite;flex:0 0 auto}
@keyframes spin{to{transform:rotate(360deg)}}
.events-error{text-align:center;padding:24px 0;color:var(--muted);font-size:13px}

/* Bardzo małe telefony */
@media (max-width:380px){
  .app{padding:12px 8px}
  .controls button{padding:8px 10px;font-size:13px}
  .cell{min-height:44px}
  .day-num{font-size:11px;padding:2px 4px 1px}
  .event-lane{height:3px}
  .event-more{font-size:8px}
}

/* Tablet i większe telefony w poziomie */
@media (min-width:600px){
  .app{padding:24px 20px}
  .app-title{font-size:1.5rem}
  .month{padding:16px}
  .month-title{font-size:18px}
  .cell{min-height:78px}
  .cell-weekday{font-size:13px}
  .day-num{font-size:14px;padding:5px 7px 2px}
  .day-events{gap:3px}
  .event-lane{height:4px}
  .day-alldot-bar{height:4px;border-radius:4px}
  .event-bar.bar-start{border-top-left-radius:4px;border-bottom-left-radius:4px}
  .event-bar.bar-end{border-top-right-radius:4px;border-bottom-right-radius:4px}
  .event-more{font-size:10px}
  .event-title{font-size:15px}
  .event-meta{font-size:13px}

  .modal-backdrop{align-items:center;padding:20px}
  .modal-panel{border-radius:16px;transform:translateY(12px) scale(.98);max-height:80vh}
  .modal-backdrop.open .modal-panel{transform:translateY(0) scale(1)}
}

/* Desktop */
@media (min-width:960px){
  .cell{min-height:70px}
  .month{padding:20px}
  .source-toggles{flex-wrap:wrap;overflow-x:visible;justify-content:center;padding-bottom:0;-webkit-mask-image:none;mask-image:none}
}
