:root {
  --c-fg-bright: #fff;
  --c-fg-text: #ccc;
  --c-fg-dull: #999;

  --c-fg-link: #ccf;
  --c-fg-varlink: #99f;

  --c-fg-warning: #f00;

  --c-bg-page: #000;
  --c-bg-panel: #334;

  --c-bg-accent: #336;
  --c-bg-highlight: #445;
  --c-bg-accent-highlight: #33a;

  --c-bg-shadow: #aaa;
}

@media (prefers-color-scheme: light) { :root {
  --c-fg-bright: #000;
  --c-fg-text: #333;
  --c-fg-dull: #666;

  --c-fg-link: #00f;
  --c-fg-varlink: #66f;

  --c-fg-warning: #f00;

  --c-bg-page: #fff;
  --c-bg-panel: #ccf;

  --c-bg-accent: #ecf;
  --c-bg-highlight: #ddf;
  --c-bg-accent-highlight: #cae;

  --c-bg-shadow: #000;
} }

/* top level styles */

body {
  margin: 0;
  padding: 0;
  color: var(--c-fg-text);
  background-color: var(--c-bg-page);
  font-size: 16px;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
}

h1,h2,h3 {
    flex: 1;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
h1 { font-size: 1.6em; text-align: center; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.1em; }

main {
  font-family: sans-serif;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: row;
}

section {
  padding: 4px;
  border: 1px solid var(--c-bg-panel);
  border-radius: 5px;
  box-sizing: border-box;
  background-color: var(--c-bg-panel);
  overflow: auto;
}

article, form {
  padding: 4px;
  margin-top: 5px;
  border-radius: 5px;
  background: var(--c-bg-page);
}

article header {
  border-bottom: 1px solid var(--c-fg-bright);
}

icon-button {
    margin-top: 0.2em;
}

icon-button button {
    font-size: 1em;
    width: 1.4em;
    height: 1.4em;
    cursor: pointer;

    color: inherit;
    background: var(--c-bg-page);

    border: 1px solid var(--c-bg-page);
    border-radius: 1em;

    display: inline-flex;
    flex-direction: column;
    align-items: center;
}
icon-button button svg {
    width: 100%;
    height: 100%;
}
icon-button button:hover {
  background: var(--c-bg-accent-highlight);
  border: 1px solid var(--c-fg-bright);
}

p {
    padding: 0;
    margin: 0;
}

pre {
  font-family: monospace;
  white-space: pre-wrap;
}

small {
  font-size: 1em;
  font-weight: 400;
}

a:link, a:visited { color: var(--c-fg-link); }
a:hover, a:active { color: var(--c-fg-varlink); }
a:link, a:visited, a:hover, a:active {
  text-decoration: None;
}

.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.divider { margin-bottom: 10px; }

.large { font-size: 1.4em; }
.warning { color: var(--c-fg-warning); }
.modal-overlay {
    position: fixed;
    top:0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;

    padding: 4px;
    border: 1px solid var(--c-fg-bright);
    border-radius: 5px;
    box-sizing: border-box;
    background-color: var(--c-bg-panel);
    display: none;
}
.modal-overlay.show {
  display: flex;
  flex-direction: column;
}

/*********************/
/* SPLIT PANELS      */
/*********************/

#left   { margin-right:  1px; }
#right  { margin-left:   1px; position: relative; width: 100%; }
#top    { margin-bottom: 1px; }
#bottom { margin-top:    1px; }

.fill-parent, .full-screen {
  width: 100% !important;
  height: 100% !important;
  top: 0;
  left: 0;
  margin: 0 !important;
}

.fill-parent { position: absolute !important; z-index: 10; }
.full-screen { position: fixed !important; z-index: 20; }

.gutter {
    background-color: var(--c-bg-page);
    background-repeat: no-repeat;
    background-position: 50%;
    opacity:0;
    transition: opacity 0.3s ease-in-out 1s;
}

.gutter:hover {
    opacity:1;
    transition: opacity 0.3s ease-in-out;
}

.gutter.gutter-horizontal {
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==');
    cursor: col-resize;
}

.gutter.gutter-vertical {
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII=');
    cursor: row-resize;
}

/*********************/
/* SEARCH BAR        */
/*********************/

.search-container {
    background: var(--c-bg-page);
    font-size: 1.2em;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    height: 1.5em;
    border: 1px solid var(--c-fg-link);
    border-radius: 1em;
    padding: 0 4px;
}

.search-container:hover,
.search-container:focus-within {
    box-shadow: 0 1px 6px var(--c-fg-dull);
    border-color: var(--c-fg-bright);
}

.search-container input {
    font-size: 1em;
    flex: 1;
    min-width: 0px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--c-fg-bold);
}

.search-container input::placeholder {
    color: var(--c-fg-dull);
}

/*********************/
/* SEARCH MODAL      */
/*********************/

#detailed-search {
    font-size: 0.8em;
    width: 30em;
    height: 19em;
}

#detailed-search form {
    display: grid;
    grid-template-columns: 1fr 3fr;
    grid-gap: 0 15px;
}

#detailed-search button,
#detailed-search select {
    font-size: 1em
}
#detailed-search input {
    border-bottom: 1px solid var(--c-fg-dull);
}

#detailed-search footer {
    flex: 1;
    position: relative;
}


/*********************/
/* TAG CONFIG        */
/*********************/

#left.editing {
  position: fixed;
  left: 0;
  z-index: 40;
  width: 50%;
  min-width: 600px;
}

#config-tags { display: initial; }
#save-tags { display: none; }
.tag-config { display: none; }

.editing #config-tags { display: none; }
.editing #save-tags { display: initial; }
.editing .tag-config { display: initial; }

.priority-value {
  display: inline-block;
  width: 16px;
  text-align: center;
}
.priority-editor {
  display: inline-block;
  margin-right: 10px;
}

.flag-emoji {
  filter: saturate(0%);
  opacity: 0.5;
}
.flag-emoji.active {
  filter: saturate(100%);
  opacity: 1;
}

/*********************/
/* TAGS              */
/*********************/

.tag { display: flex; }
.tag.selected { background: var(--c-bg-accent); }
.tag:hover { background: var(--c-bg-highlight); }
.tag.selected:hover { background: var(--c-bg-accent-highlight); }

.tag .tag-name {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.tag.parent-tag .tag-toggle,
.tag.child-tag .tag-toggle {
    padding: 2px 5px;
    width: 0.75em;
    display: inline-block;
    font-size: 0.7em;
}
.tag.parent-tag          .tag-toggle::before { content: "▶"; }
.tag.parent-tag.expanded .tag-toggle::before { content: "▼"; }

/*********************/
/* TAG TYPES         */
/*********************/

/*   FOLDERS         */

.subfolder {
    padding-left: 0.75em;
    display: none;
}

#subfolder- {
    padding-left: 0;
    display: inherit;
}

.subfolder.expanded {
    display: inherit;
}

/*   TAGS            */

.tag-tag {
    display: inline-block;
    border: 1px solid var(--c-fg-dull);
    border-radius: 1em;
    padding: 0.25em;
}

.editing .tag-tag {
    display: flex;
    border: initial;
    border-radius: initial;
    padding: initial;
}

/*********************/
/* SEARCH HINTS      */
/*********************/

#search-hints h2 {
  font-size: 1.8em;
  font-weight: 300;
}

#search-hints pre, #search-hints code {
  font-family: monospace;
}
#search-hints {
  margin-top: 50px;
}
#search-hints code {
  background-color: var(--c-bg-highlight);
  font-weight: 400;
  border-radius: 3px;
  padding: 1.5px 4.5px;
}
#search-hints pre {
  font-weight: 400;
  margin: 15px 0;
  opacity: 0.9;
  padding: 15px 20px;
  border: 1px solid var(--c-fg-bright);
  border-radius: 5px;
}

/*********************/
/* INDEX             */
/*********************/

#index {
  overflow: auto;
  padding: 0;
}

.thread-container {
  padding: 3px 0;
  border-bottom: 1px solid var(--c-fg-bright);
  cursor: pointer;
}

.thread-container.selected { background: var(--c-bg-accent); }
.thread-container:hover { background: var(--c-bg-highlight); }
.thread-container.selected:hover { background: var(--c-bg-accent-highlight); }

.thread-container > .from,
.thread-container > .subject,
.thread-container > .time {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
  padding: 0;
}

.thread-container > .subject {
  width: calc(100% - 18em - 30px);
  padding-right: 10px;
}

.thread-container > .from {
  width: 12em;
  padding: 0 10px 0 5px;
}

.thread-container > .time {
  padding-right: 5px;
  width: 6em;
  text-align: right;
}

/*********************/
/* PAGER             */
/*********************/

.message-subject { font-weight: 500; }
.message-from { font-weight: 900; }
.message-to { font-weight: 400; opacity: 0.6; }

pre details {
  margin-top: 1em;
  padding-left: 0.25em;
  border-left: 2px solid var(--c-fg-text);
}

/* Nested depth gets slightly lighter */
pre details details {
  border-left-color: var(--c-fg-dull);
}

/* Summary line */
details summary {
  cursor: pointer;
  color: var(--c-fg-dull);
}

/* Prevent extra vertical space when open */
details[open] > summary {
  color: var(--c-fg-text);
}

/*********************/
/* RESPONSIVE LAYOUT */
/*********************/

#backdrop {
  height: 100vh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;

  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 35;
}

#backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* -------- Desktop -------- */
@media (min-width: 768px) {
  #menu { display: none; }
}

/* -------- Mobile -------- */
@media (max-width: 767px) {
  section {
    padding-left: 0;
    padding-right: 0;
  }

  #right {
    width: 100%;
    margin: 0;
  }

  #left {
    position: fixed;
    left: 0;
    width: 192px;
    padding: 3px;
    max-width: 85%;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    z-index: 40;
  }

  #left.open { transform: translateX(0); }
}
