:root {
  color-scheme: light;
  --face: #d4d0c8;
  --shadow: #808080;
  --light: #ffffff;
  --dark: #0a246a;
  --text: #111111;
  --link: #0046d5;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 12px;
  background: #3a6ea5;
  color: var(--text);
}

button, input {
  font: inherit;
}

button {
  min-height: 24px;
  padding: 2px 10px;
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  background: var(--face);
  color: #000;
}

button:active {
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

button:disabled {
  color: #777;
}

input {
  height: 23px;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  padding: 2px 6px;
  background: #fff;
}

.app {
  width: min(1180px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 24px));
  margin: 12px auto;
  display: grid;
  grid-template-rows: 26px 34px 1fr 22px;
  border: 2px solid;
  border-color: var(--light) #404040 #404040 var(--light);
  background: var(--face);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 5px;
  color: #fff;
  background: linear-gradient(90deg, #0a246a, #a6caf0);
  font-weight: 700;
}

.window-buttons {
  display: flex;
  gap: 3px;
}

.window-buttons span {
  width: 16px;
  height: 16px;
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border-bottom: 1px solid var(--shadow);
  overflow: auto;
  white-space: nowrap;
}

.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.toolbar input {
  width: 140px;
}

.panic {
  margin-left: auto;
  background: #e7d3d3;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 150px;
  gap: 5px;
  padding: 5px;
}

.tree, .nicklist, .chat-window {
  min-height: 0;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: #fff;
}

.tree, .nicklist {
  padding: 6px;
  overflow: auto;
}

.tree-title {
  margin-bottom: 6px;
  font-weight: 700;
}

.tree-item {
  padding: 3px 5px;
}

.tree-item.active {
  background: var(--dark);
  color: #fff;
}

.chat-window {
  display: grid;
  grid-template-rows: 22px minmax(0, 1fr) 31px;
}

.chat-title {
  padding: 4px 7px;
  border-bottom: 1px solid #b8b8b8;
  background: #efefef;
  font-weight: 700;
}

.messages {
  min-height: 0;
  padding: 6px 8px;
  overflow: auto;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.line .time { color: #666; }
.line .nick { color: var(--link); font-weight: 700; }
.line.notice { color: #7a4a00; }
.line.error { color: #b00020; font-weight: 700; }
.line.action { color: #6b1b8f; }

.inputbar {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 5px;
  padding: 4px;
  border-top: 1px solid #b8b8b8;
}

.inputbar input {
  width: 100%;
}

.nick {
  padding: 2px 0;
  color: #003399;
  cursor: default;
}

.statusline {
  padding: 3px 6px;
  border-top: 1px solid var(--shadow);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hidden { display: none !important; }

.nick-menu {
  position: fixed;
  z-index: 20;
  min-width: 190px;
  padding: 3px;
  border: 2px solid;
  border-color: var(--light) var(--shadow) var(--shadow) var(--light);
  background: var(--face);
  box-shadow: 3px 3px 0 rgba(0,0,0,.24);
}

.nick-menu button {
  width: 100%;
  border-width: 1px;
  text-align: left;
}

.sheet {
  min-height: 100vh;
  background: #f3f6f4;
  color: #162116;
  font-family: Arial, sans-serif;
}

.sheet-ribbon {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  background: #217346;
  color: #fff;
}

.sheet-ribbon button {
  margin-left: auto;
}

.sheet-grid {
  width: min(1120px, calc(100vw - 28px));
  margin: 18px auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.chart-panel, .sheet table {
  background: #fff;
  border: 1px solid #c9d7cc;
}

.chart-panel {
  padding: 18px;
}

.chart-panel h1 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 600;
}

.bars {
  height: 310px;
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 20px;
  border-left: 1px solid #d7dfd9;
  border-bottom: 1px solid #d7dfd9;
  background: repeating-linear-gradient(to top, #fff, #fff 38px, #eef4f0 39px);
}

.bars span {
  flex: 1;
  height: var(--h);
  background: linear-gradient(#69a7e7, #2368a9);
}

.sheet table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.sheet th, .sheet td {
  border: 1px solid #c9d7cc;
  padding: 10px;
  text-align: right;
}

.sheet th:first-child, .sheet td:first-child,
.sheet th:last-child, .sheet td:last-child {
  text-align: left;
}

.sheet th {
  background: #e2f0d9;
}

@media (max-width: 780px) {
  .app {
    width: 100vw;
    height: 100vh;
    margin: 0;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
  .tree, .nicklist {
    display: none;
  }
  .toolbar {
    align-items: stretch;
  }
  .toolbar input {
    width: 110px;
  }
  .sheet-grid {
    grid-template-columns: 1fr;
  }
}
