:root {
    --text: #252525;
    --bg: #fff;
    --backdrop: #eee;
    --muted: #777;
    --link: #00f;
    --link-hover: #6491ff;
    --border: #ddd;
    --input-border: #bbb;
    --input-focus: #00f;
    --error: #d00;
    --btn-bg: linear-gradient(#f6f5f4, #edebe9);
    --btn-border: #e9e9e9;
    --btn-border-outset: #ccc;
    --btn-hover-bg: linear-gradient(#f0f0f0, #d0cecc);
    --btn-active-bg: linear-gradient(#d0cecc, #f0f0f0);
    --nav-bg: #f8f8d9;
    --nav-border: #dede89;
}

* { box-sizing: border-box; }

html {
    font: 14px/160% Lato, sans-serif;
    color: var(--text);
    background: var(--backdrop);
}

body { margin: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

.page {
    max-width: 76rem;
    margin: .5rem auto;
    padding: 1rem 2rem 2rem;
    background: var(--bg);
    box-shadow: 0 0 6px rgba(0, 0, 0, .2);
}

#toast {
    position: sticky;
    top: .5rem;
    z-index: 1;
    margin: 0 0 1em;
    padding: .5em .8em;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 3px;
}

header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: .2em;
    margin-bottom: 1em;
    border-bottom: 1px solid var(--text);
}

h1 { margin: 0; font-size: 1.7em; }
h2 { margin: 0 0 .5em; font-size: 1.3em; }

h3 {
    margin: 1.2em 0 .3em;
    padding-bottom: .1em;
    font-size: 1em;
    border-bottom: 1px solid var(--text);
}

input, select, textarea {
    font: inherit;
    line-height: 100%;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--input-border);
    border-radius: 3px;
    padding: .5em;
}

textarea { line-height: 130%; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: 1px solid var(--input-focus);
    box-shadow: 0 0 .2em var(--input-focus);
}

input.invalid, textarea.invalid { border-color: var(--error); }

button {
    font: inherit;
    cursor: pointer;
    padding: .4em 1em;
    color: var(--text);
    background: var(--btn-bg);
    border: 1px outset var(--btn-border);
    border-top-color: var(--btn-border-outset);
    border-left-color: var(--btn-border-outset);
    border-radius: 3px;
}

button:hover { background: var(--btn-hover-bg); }
button:active { background: var(--btn-active-bg); border-style: inset; }

label { display: block; margin-top: .6em; }
label.inline { display: inline; margin-right: .5em; }

[data-for] {
    display: block;
    min-height: 1.3em;
    color: var(--muted);
    font-size: .85em;
}

.error, [data-for].error { color: var(--error); }
p[data-for] { margin: .5em 0 0; }

#auth {
    max-width: 22rem;
    margin: 3em auto;
}

#auth input { width: 100%; }
#auth p:last-child { margin: 1em 0 0; }

#app {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

#app section { flex: 1; min-width: 0; }

aside {
    width: 15rem;
    flex-shrink: 0;
}

aside ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

aside li {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#lists li.selected { font-weight: bold; }
#lists:empty::before { content: 'списков пока нет'; color: var(--muted); }

.swatch {
    display: inline-block;
    width: .8em;
    height: .8em;
    border: 1px solid var(--input-border);
    vertical-align: middle;
}

#list-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .3em;
    margin-top: .5em;
}

#list-form input[name=name] { flex: 1; min-width: 0; }
#list-form input[type=color] { width: 2.2em; height: 2.2em; padding: .15em; }
#list-form [data-for] { width: 100%; }

#undated {
    min-height: 3.5em;
    padding: .3em .4em;
    border: 1px dashed var(--input-border);
    border-radius: 3px;
}

#undated:empty::before { content: 'перетащите задачу сюда, чтобы снять срок'; color: var(--muted); white-space: normal; }
#undated li, #calendar li { padding: 0 .2em; border-left: 3px solid transparent; border-radius: 2px; cursor: grab; }
#undated li.priority-high, #calendar li.priority-high { border-left-color: #c00; }
#undated li.priority-medium, #calendar li.priority-medium { border-left-color: #e6a700; }
.legend .swatch.priority-high { background: #c00; border-color: #c00; }
.legend .swatch.priority-medium { background: #e6a700; border-color: #e6a700; }
.reminder-at { color: var(--muted); font-size: .85em; }
#undated li:hover, #calendar li:hover { background: var(--backdrop); }
#undated li.completed, #calendar li.completed { color: #999; text-decoration: line-through; }
#undated.drop, #calendar td.drop { outline: 2px solid var(--text); outline-offset: -2px; }

#month-nav {
    display: flex;
    align-items: center;
    gap: .5em;
    margin: 0 0 1em;
    padding: .5em .8em;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 3px;
}

#month-title {
    min-width: 10em;
    text-align: center;
    text-transform: capitalize;
}

#new-task { margin-left: auto; }

.tabs { display: inline-flex; margin-left: .5em; }
.tabs .tab { border-radius: 0; }
.tabs .tab:first-child { border-radius: 3px 0 0 3px; }
.tabs .tab:last-child { border-radius: 0 3px 3px 0; }
.tabs .tab.active { background: var(--bg); border-style: inset; }

#reminders ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#reminders li { padding: .15em 0; }
#reminders li.overdue a { font-weight: bold; }
#upcoming:empty::before { content: 'нет запланированных напоминаний'; color: var(--muted); }
#sent:empty::before { content: 'ещё ничего не отправлено'; color: var(--muted); }

#filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5em;
    margin: 0 0 1em;
}

#filters input[name=q] { flex: 1; min-width: 12em; }
#filters label { margin: 0; }
#filters button { padding: .3em .8em; }

#calendar {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

#calendar th {
    padding: .2em .4em;
    font-weight: normal;
    color: var(--muted);
    text-align: left;
}

#calendar td {
    height: 6.5em;
    padding: .3em .4em;
    vertical-align: top;
    border: 1px solid var(--border);
}

#calendar td.other { background: #f7f7f7; color: #aaa; }
#calendar td.today { background: var(--nav-bg); }
#calendar .day { font-size: .9em; color: var(--muted); }
#calendar td.today .day { font-weight: bold; color: var(--text); }

#calendar ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

#calendar li {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#calendar li.overdue { font-weight: bold; }

.legend {
    margin: .5em 0 0;
    font-size: .85em;
    color: var(--muted);
}

dialog {
    width: 30rem;
    padding: 1.2em 1.5em;
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(0, 0, 0, .2);
}

dialog::backdrop { background: rgba(0, 0, 0, .3); }

#task-form input:not([type=checkbox]):not([type=number]), #task-form select, #task-form textarea { width: 100%; }
#task-form input[type=number] { width: 4.5em; }
#task-form .row { display: flex; gap: 1em; }
#task-form .row label { flex: 1; min-width: 0; }
#task-form #recurrence { margin-top: .4em; padding: .5em .8em; border: 1px solid var(--border); border-radius: 3px; }
#task-form #days-of-week { margin: .5em 0; }
#task-form .actions { display: flex; gap: .5em; margin: 1em 0 0; }
#task-form #cancel { margin-left: auto; }
