* { box-sizing: border-box; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body { margin: 0; background: #f2f4f7; color: #1d2433; }

header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #1d2433; color: #fff; }
header h1 { margin: 0; font-size: 18px; }
header h1 span { font-weight: 400; opacity: .7; font-size: 14px; margin-left: 8px; }
header > div { display: flex; gap: 8px; align-items: center; }

.btn, button, select { padding: 6px 12px; border: 1px solid #c5ccd8; background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; color: #1d2433; }
button:disabled { opacity: .5; cursor: wait; }
.primary { background: #e8590c; color: #fff; border-color: #e8590c; }
.ok-btn { background: #2b8a3e; color: #fff; border-color: #2b8a3e; }
.ghost { background: transparent; color: #fff; border-color: #4a5468; }
.ghost-dark { font-size: 12px; padding: 3px 8px; }

#toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 16px; background: #fff; border-bottom: 1px solid #dde2ea; }
#status { font-size: 13px; color: #e8590c; margin-left: 8px; }
#zoomInfo, #pageInfo { font-size: 13px; min-width: 40px; text-align: center; }
.tool.active { background: #1d2433; color: #fff; }
.sep { width: 1px; height: 24px; background: #dde2ea; margin: 0 4px; }

main { display: flex; height: calc(100vh - 110px); }
#canvasWrap { flex: 1; overflow: auto; position: relative; }
#stage { position: relative; display: inline-block; }
#pageImg { display: block; }
#overlay { position: absolute; top: 0; left: 0; }
#empty { position: absolute; top: 30%; width: 100%; text-align: center; color: #8a93a5; }
#recent { display: inline-block; text-align: left; margin-top: 10px; }
#recent a { display: block; color: #1971c2; cursor: pointer; padding: 3px 0; font-size: 14px; }

aside { width: 340px; background: #fff; border-left: 1px solid #dde2ea; padding: 12px; overflow: auto; }
aside h2 { font-size: 14px; margin: 14px 0 6px; }
aside ul { list-style: none; padding: 0; margin: 0; font-size: 13px; }
aside li { padding: 4px 6px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
aside li:hover { background: #f2f4f7; }
aside li button { padding: 1px 6px; font-size: 12px; }
#details { font-size: 13px; }
#details label { display: block; font-size: 12px; margin-top: 6px; }
#details input, #details select, #details textarea { width: 100%; padding: 4px; font-size: 13px; }
#details .row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#details fieldset { border: 1px solid #dde2ea; border-radius: 6px; margin-top: 10px; padding: 6px 8px; }
#details .meta { color: #5c667a; font-size: 12px; }
#issues li { color: #c92a2a; cursor: default; }
#issues li.ok { color: #2b8a3e; }

.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; color: #fff; white-space: nowrap; }
.b-confirmed { background: #2b8a3e; }
.b-unconfirmed { background: #e8590c; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.overlay .box { background: #fff; padding: 24px; border-radius: 10px; width: 500px; max-height: 90vh; overflow: auto; }
.overlay h3 { margin-top: 0; }
.overlay textarea { width: 100%; margin-bottom: 10px; padding: 6px; }
.overlay label { display: block; margin: 8px 0; font-size: 14px; }
.overlay input, .overlay label select { width: 100%; padding: 6px; margin-top: 3px; }
.overlay fieldset { border: 1px solid #dde2ea; border-radius: 6px; margin: 10px 0; }
.overlay button { margin-right: 6px; }
.small { font-size: 12px; color: #5c667a; }
#keyState { font-size: 12px; color: #2b8a3e; margin-left: 6px; }
#testResult { font-size: 13px; min-height: 18px; }
#testResult.bad { color: #c92a2a; }
#testResult.good { color: #2b8a3e; }

.hidden { display: none !important; }

/* Login + project list */
.bad-text { color: #c92a2a; font-size: 13px; min-height: 16px; }
#recent .proj { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
#recent .proj button { padding: 1px 6px; font-size: 12px; }
#loginModal { background: #1d2433; }
code { background: #f2f4f7; padding: 1px 4px; border-radius: 3px; font-size: 12px; }

/* Phones and narrow screens: stack everything instead of side by side */
@media (max-width: 800px) {
  header { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  header h1 { font-size: 16px; }
  header h1 span { display: block; margin-left: 0; font-size: 12px; }
  header > div { flex-wrap: wrap; gap: 6px; }
  .btn, button, select { padding: 6px 10px; font-size: 13px; }
  #toolbar { padding: 6px 8px; gap: 4px; }
  .sep { display: none; }
  main { flex-direction: column; height: auto; }
  #canvasWrap { flex: none; height: 65vh; }
  aside { width: 100%; border-left: 0; border-top: 1px solid #dde2ea; }
  #empty { position: static; padding: 32px 16px; }
  #recent { display: block; }
  #recent .proj a { overflow-wrap: anywhere; }
  .overlay .box { width: calc(100vw - 24px); padding: 16px; }
  /* drawing list screen: nothing to show in the side panel yet */
  body.home aside { display: none; }
  body.home #canvasWrap { height: auto; }
}

/* Twin view + connection list */
#twin { background: #fff; min-height: 100%; padding: 8px; }
#twin svg { display: block; }
#twin .node { cursor: pointer; }
#twin .node:hover .sym { stroke-width: 3; }
.conn-list li { cursor: default; }
.conn-list .auto { color: #e8590c; }
.conn-list button { margin-left: 4px; }
